Args: *args: extra arguments for SMPL initialization. keypoint_src: source convention of keypoints. This convention is used for keypoints obtained from joint regressors. Keypoints then undergo conversion into keypoint_dst
(self,
*args,
keypoint_src: str = 'smpl_45',
keypoint_dst: str = 'human_data',
keypoint_approximate: bool = False,
joints_regressor: str = None,
extra_joints_regressor: str = None,
**kwargs)
| 31 | NUM_FACES = 13776 |
| 32 | |
| 33 | def __init__(self, |
| 34 | *args, |
| 35 | keypoint_src: str = 'smpl_45', |
| 36 | keypoint_dst: str = 'human_data', |
| 37 | keypoint_approximate: bool = False, |
| 38 | joints_regressor: str = None, |
| 39 | extra_joints_regressor: str = None, |
| 40 | **kwargs) -> None: |
| 41 | """ |
| 42 | Args: |
| 43 | *args: extra arguments for SMPL initialization. |
| 44 | keypoint_src: source convention of keypoints. This convention |
| 45 | is used for keypoints obtained from joint regressors. |
| 46 | Keypoints then undergo conversion into keypoint_dst |
| 47 | convention. |
| 48 | keypoint_dst: destination convention of keypoints. This convention |
| 49 | is used for keypoints in the output. |
| 50 | keypoint_approximate: whether to use approximate matching in |
| 51 | convention conversion for keypoints. |
| 52 | joints_regressor: path to joint regressor. Should be a .npy |
| 53 | file. If provided, replaces the official J_regressor of SMPL. |
| 54 | extra_joints_regressor: path to extra joint regressor. Should be |
| 55 | a .npy file. If provided, extra joints are regressed and |
| 56 | concatenated after the joints regressed with the official |
| 57 | J_regressor or joints_regressor. |
| 58 | **kwargs: extra keyword arguments for SMPL initialization. |
| 59 | |
| 60 | Returns: |
| 61 | None |
| 62 | """ |
| 63 | super(SMPL, self).__init__(*args, **kwargs) |
| 64 | # joints = [JOINT_MAP[i] for i in JOINT_NAMES] |
| 65 | self.keypoint_src = keypoint_src |
| 66 | self.keypoint_dst = keypoint_dst |
| 67 | self.keypoint_approximate = keypoint_approximate |
| 68 | # override the default SMPL joint regressor if available |
| 69 | if joints_regressor is not None: |
| 70 | joints_regressor = torch.tensor(np.load(joints_regressor), |
| 71 | dtype=torch.float) |
| 72 | self.register_buffer('joints_regressor', joints_regressor) |
| 73 | |
| 74 | # allow for extra joints to be regressed if available |
| 75 | if extra_joints_regressor is not None: |
| 76 | joints_regressor_extra = torch.tensor( |
| 77 | np.load(extra_joints_regressor), dtype=torch.float) |
| 78 | self.register_buffer('joints_regressor_extra', |
| 79 | joints_regressor_extra) |
| 80 | |
| 81 | self.num_verts = self.get_num_verts() |
| 82 | self.num_joints = get_keypoint_num(convention=self.keypoint_dst) |
| 83 | self.body_part_segmentation = body_segmentation('smpl') |
| 84 | |
| 85 | def forward(self, |
| 86 | *args, |
no test coverage detected