MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / __init__

Method __init__

detrsmpl/models/heads/expose_head.py:298–352  ·  view source on GitHub ↗
(self,
                 init_cfg=None,
                 num_betas: int = 10,
                 num_expression_coeffs: int = 10,
                 mean_pose_path: str = '',
                 shape_mean_path: str = '',
                 pose_param_conf: list = None,
                 input_feat_dim: int = 2048,
                 regressor_cfg: dict = None,
                 camera_cfg: dict = None)

Source from the content-addressed store, hash-verified

296class ExPoseBodyHead(ExPoseHead):
297 """Head for ExPose Body Model."""
298 def __init__(self,
299 init_cfg=None,
300 num_betas: int = 10,
301 num_expression_coeffs: int = 10,
302 mean_pose_path: str = '',
303 shape_mean_path: str = '',
304 pose_param_conf: list = None,
305 input_feat_dim: int = 2048,
306 regressor_cfg: dict = None,
307 camera_cfg: dict = None):
308 super().__init__(init_cfg)
309 self.num_betas = num_betas
310 self.num_expression_coeffs = num_expression_coeffs
311 # poses
312 self.pose_param_conf = pose_param_conf
313 mean_poses_dict = {}
314 if os.path.exists(mean_pose_path):
315 with open(mean_pose_path, 'rb') as f:
316 mean_poses_dict = pickle.load(f)
317 start, mean_lst = self.load_param_decoder(mean_poses_dict)
318
319 # shape
320 if os.path.exists(shape_mean_path):
321 shape_mean = torch.from_numpy(
322 np.load(shape_mean_path,
323 allow_pickle=True)).to(dtype=torch.float32).reshape(
324 1, -1)[:, :num_betas].reshape(-1)
325 else:
326 shape_mean = torch.zeros([num_betas], dtype=torch.float32)
327 shape_idxs = list(range(start, start + num_betas))
328 self.register_buffer('shape_idxs',
329 torch.tensor(shape_idxs, dtype=torch.long))
330 start += num_betas
331 mean_lst.append(shape_mean.view(-1))
332
333 # expression
334 expression_mean = torch.zeros([num_expression_coeffs],
335 dtype=torch.float32)
336 expression_idxs = list(range(start, start + num_expression_coeffs))
337 self.register_buffer('expression_idxs',
338 torch.tensor(expression_idxs, dtype=torch.long))
339 start += num_expression_coeffs
340 mean_lst.append(expression_mean.view(-1))
341
342 # camera
343 mean, dim, scale_func = self.get_camera_param(camera_cfg)
344 self.camera_scale_func = scale_func
345 camera_idxs = list(range(start, start + dim))
346 self.register_buffer('camera_idxs',
347 torch.tensor(camera_idxs, dtype=torch.long))
348 start += dim
349 mean_lst.append(mean)
350
351 param_mean = torch.cat(mean_lst).view(1, -1)
352 self.load_regressor(input_feat_dim, param_mean, regressor_cfg)
353
354 def forward(self, features):
355 """Forward function of ExPose Body Head.

Callers

nothing calls this directly

Calls 6

load_param_decoderMethod · 0.80
get_camera_paramMethod · 0.80
load_regressorMethod · 0.80
__init__Method · 0.45
loadMethod · 0.45
toMethod · 0.45

Tested by

no test coverage detected