(self,
init_cfg=None,
num_betas: int = 10,
num_expression_coeffs: int = 10,
pose_param_conf: list = None,
mean_pose_path: str = '',
input_feat_dim: int = 2048,
regressor_cfg: dict = None,
camera_cfg: dict = None)
| 448 | class ExPoseFaceHead(ExPoseHead): |
| 449 | """Head for ExPose Face Model.""" |
| 450 | def __init__(self, |
| 451 | init_cfg=None, |
| 452 | num_betas: int = 10, |
| 453 | num_expression_coeffs: int = 10, |
| 454 | pose_param_conf: list = None, |
| 455 | mean_pose_path: str = '', |
| 456 | input_feat_dim: int = 2048, |
| 457 | regressor_cfg: dict = None, |
| 458 | camera_cfg: dict = None): |
| 459 | super().__init__(init_cfg) |
| 460 | self.num_betas = num_betas |
| 461 | self.num_expression_coeffs = num_expression_coeffs |
| 462 | # poses |
| 463 | self.pose_param_conf = pose_param_conf |
| 464 | mean_poses_dict = {} |
| 465 | if os.path.exists(mean_pose_path): |
| 466 | with open(mean_pose_path, 'rb') as f: |
| 467 | mean_poses_dict = pickle.load(f) |
| 468 | start, mean_lst = self.load_param_decoder(mean_poses_dict) |
| 469 | |
| 470 | # shape |
| 471 | shape_mean = torch.zeros([num_betas], dtype=torch.float32) |
| 472 | shape_idxs = list(range(start, start + num_betas)) |
| 473 | self.register_buffer('shape_idxs', |
| 474 | torch.tensor(shape_idxs, dtype=torch.long)) |
| 475 | start += num_betas |
| 476 | mean_lst.append(shape_mean.view(-1)) |
| 477 | |
| 478 | # expression |
| 479 | expression_mean = torch.zeros([num_expression_coeffs], |
| 480 | dtype=torch.float32) |
| 481 | expression_idxs = list(range(start, start + num_expression_coeffs)) |
| 482 | self.register_buffer('expression_idxs', |
| 483 | torch.tensor(expression_idxs, dtype=torch.long)) |
| 484 | start += num_expression_coeffs |
| 485 | mean_lst.append(expression_mean.view(-1)) |
| 486 | |
| 487 | # camera |
| 488 | mean, dim, scale_func = self.get_camera_param(camera_cfg) |
| 489 | self.camera_scale_func = scale_func |
| 490 | camera_idxs = list(range(start, start + dim)) |
| 491 | self.register_buffer('camera_idxs', |
| 492 | torch.tensor(camera_idxs, dtype=torch.long)) |
| 493 | start += dim |
| 494 | mean_lst.append(mean) |
| 495 | |
| 496 | param_mean = torch.cat(mean_lst).view(1, -1) |
| 497 | self.load_regressor(input_feat_dim, param_mean, regressor_cfg) |
| 498 | self.avgpool = nn.AdaptiveAvgPool2d((1, 1)) |
| 499 | |
| 500 | def forward(self, features, cond=None): |
| 501 | """Forward function of ExPose Face Head. |
nothing calls this directly
no test coverage detected