Extension of the official SMPL implementation.
| 17 | |
| 18 | |
| 19 | class SMPL(_SMPL): |
| 20 | """Extension of the official SMPL implementation.""" |
| 21 | |
| 22 | body_pose_keys = { |
| 23 | 'global_orient', |
| 24 | 'body_pose', |
| 25 | } |
| 26 | full_pose_keys = { |
| 27 | 'global_orient', |
| 28 | 'body_pose', |
| 29 | } |
| 30 | NUM_VERTS = 6890 |
| 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( |