Decode model parameters to smplx vertices & joints & texture Args: param_dict: smplx parameters param_type: should be one of body/head/hand Returns: predictions: smplx predictions
(self, param_dict, param_type, extra=None,**kwargs)
| 489 | return param_dict |
| 490 | |
| 491 | def decode(self, param_dict, param_type, extra=None,**kwargs): |
| 492 | ''' Decode model parameters to smplx vertices & joints & texture |
| 493 | Args: |
| 494 | param_dict: smplx parameters |
| 495 | param_type: should be one of body/head/hand |
| 496 | Returns: |
| 497 | predictions: smplx predictions |
| 498 | ''' |
| 499 | if 'jaw_pose' in param_dict.keys() and len(param_dict['jaw_pose'].shape) == 2: |
| 500 | self.convert_pose(param_dict, param_type) |
| 501 | elif param_dict['right_wrist_pose'].shape[-1] == 6: |
| 502 | self.convert_pose(param_dict, param_type) |
| 503 | |
| 504 | # concatenate body pose |
| 505 | partbody_pose = param_dict['partbody_pose'] |
| 506 | param_dict['body_pose'] = torch.cat( |
| 507 | [partbody_pose[:, :11], |
| 508 | param_dict['neck_pose'], |
| 509 | partbody_pose[:, 11:11+2], |
| 510 | param_dict['head_pose'], |
| 511 | partbody_pose[:, 13:13+4], |
| 512 | param_dict['left_wrist_pose'], |
| 513 | param_dict['right_wrist_pose']], dim=1) |
| 514 | |
| 515 | # change absolute head&hand pose to relative pose according to rest body pose |
| 516 | if param_type == 'head' or param_type == 'body': |
| 517 | param_dict['body_pose'] = self.smplx.pose_abs2rel( |
| 518 | param_dict['global_pose'], |
| 519 | param_dict['body_pose'], |
| 520 | abs_joint='head') |
| 521 | if param_type == 'hand' or param_type == 'body': |
| 522 | param_dict['body_pose'] = self.smplx.pose_abs2rel( |
| 523 | param_dict['global_pose'], |
| 524 | param_dict['body_pose'], |
| 525 | abs_joint='left_wrist') |
| 526 | param_dict['body_pose'] = self.smplx.pose_abs2rel( |
| 527 | param_dict['global_pose'], |
| 528 | param_dict['body_pose'], |
| 529 | abs_joint='right_wrist') |
| 530 | |
| 531 | if self.cfg.model.check_pose: |
| 532 | # check if pose is natural (relative rotation), if not, set relative to 0 (especially for head pose) |
| 533 | # xyz: pitch(positive for looking down), yaw(positive for looking left), roll(rolling chin to left) |
| 534 | for pose_ind in [14]: # head [15-1, 20-1, 21-1]: |
| 535 | curr_pose = param_dict['body_pose'][:, pose_ind] |
| 536 | euler_pose = converter._compute_euler_from_matrix(curr_pose) |
| 537 | for i, max_angle in enumerate([20, 70, 10]): |
| 538 | euler_pose_curr = euler_pose[:, i] |
| 539 | euler_pose_curr[ |
| 540 | euler_pose_curr != |
| 541 | torch.clamp( |
| 542 | euler_pose_curr, |
| 543 | min=-max_angle*np.pi/180, |
| 544 | max=max_angle*np.pi/180) |
| 545 | ] = 0. |
| 546 | param_dict['body_pose'][:, |
| 547 | pose_ind] = converter.batch_euler2matrix(euler_pose) |
| 548 |
no test coverage detected