Forward function. Args: *args: extra arguments for SMPL return_verts: whether to return vertices return_full_pose: whether to return full pose parameters **kwargs: extra arguments for SMPL Returns: output: contains output
(self,
*args,
return_verts: bool = True,
return_full_pose: bool = False,
**kwargs)
| 317 | self.body_part_segmentation = body_segmentation('smplx') |
| 318 | |
| 319 | def forward(self, |
| 320 | *args, |
| 321 | return_verts: bool = True, |
| 322 | return_full_pose: bool = False, |
| 323 | **kwargs) -> dict: |
| 324 | """Forward function. |
| 325 | |
| 326 | Args: |
| 327 | *args: extra arguments for SMPL |
| 328 | return_verts: whether to return vertices |
| 329 | return_full_pose: whether to return full pose parameters |
| 330 | **kwargs: extra arguments for SMPL |
| 331 | |
| 332 | Returns: |
| 333 | output: contains output parameters and attributes |
| 334 | """ |
| 335 | |
| 336 | kwargs['get_skin'] = True |
| 337 | smplx_output = super(SMPLXLayer, self).forward(*args, **kwargs) |
| 338 | |
| 339 | if not hasattr(self, 'joints_regressor'): |
| 340 | joints = smplx_output.joints |
| 341 | else: |
| 342 | joints = vertices2joints(self.joints_regressor, |
| 343 | smplx_output.vertices) |
| 344 | |
| 345 | if hasattr(self, 'joints_regressor_extra'): |
| 346 | extra_joints = vertices2joints(self.joints_regressor_extra, |
| 347 | smplx_output.vertices) |
| 348 | joints = torch.cat([joints, extra_joints], dim=1) |
| 349 | |
| 350 | joints, joint_mask = convert_kps(joints, |
| 351 | src=self.keypoint_src, |
| 352 | dst=self.keypoint_dst, |
| 353 | approximate=self.keypoint_approximate) |
| 354 | if isinstance(joint_mask, np.ndarray): |
| 355 | joint_mask = torch.tensor(joint_mask, |
| 356 | dtype=torch.uint8, |
| 357 | device=joints.device) |
| 358 | |
| 359 | batch_size = joints.shape[0] |
| 360 | joint_mask = joint_mask.reshape(1, -1).expand(batch_size, -1) |
| 361 | |
| 362 | output = dict(global_orient=smplx_output.global_orient, |
| 363 | body_pose=smplx_output.body_pose, |
| 364 | joints=joints, |
| 365 | joint_mask=joint_mask, |
| 366 | keypoints=torch.cat([joints, joint_mask[:, :, None]], |
| 367 | dim=-1), |
| 368 | betas=smplx_output.betas) |
| 369 | |
| 370 | if return_verts: |
| 371 | output['vertices'] = smplx_output.vertices |
| 372 | if return_full_pose: |
| 373 | output['full_pose'] = smplx_output.full_pose |
| 374 | |
| 375 | return output |
nothing calls this directly
no test coverage detected