MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / __call__

Method __call__

detrsmpl/models/utils/SMPLX.py:35–90  ·  view source on GitHub ↗

Function Args: body_predictions (dict): The prediction from body model. hand_predictions (dict): The prediction from hand model. Returns: dict: Merged prediction.

(self, body_predictions, hand_predictions)

Source from the content-addressed store, hash-verified

33 self.right_wrist_idx, self.body_model.parents)
34
35 def __call__(self, body_predictions, hand_predictions):
36 """Function
37 Args:
38 body_predictions (dict): The prediction from body model.
39 hand_predictions (dict): The prediction from hand model.
40 Returns:
41 dict: Merged prediction.
42 """
43 pred_param = body_predictions['pred_param']
44 global_orient = pred_param['global_orient']
45 body_pose = pred_param['body_pose']
46 pred_cam = body_predictions['pred_cam']
47 batch_size = pred_cam.shape[0]
48 device = pred_cam.device
49 hands_from_body_idxs = torch.arange(0,
50 2 * batch_size,
51 dtype=torch.long,
52 device=device)
53 right_hand_from_body_idxs = hands_from_body_idxs[:batch_size]
54 left_hand_from_body_idxs = hands_from_body_idxs[batch_size:]
55
56 parent_rots = []
57 right_wrist_parent_rot = find_joint_global_rotation(
58 self.right_wrist_kin_chain[1:], global_orient, body_pose)
59
60 left_wrist_parent_rot = find_joint_global_rotation(
61 self.left_wrist_kin_chain[1:], global_orient, body_pose)
62 left_to_right_wrist_parent_rot = flip_rotmat(left_wrist_parent_rot)
63
64 parent_rots += [right_wrist_parent_rot, left_to_right_wrist_parent_rot]
65 parent_rots = torch.cat(parent_rots, dim=0)
66
67 wrist_pose_from_hand = hand_predictions['pred_param']['global_orient']
68 # Undo the rotation of the parent joints to make the wrist rotation
69 # relative again
70 wrist_pose_from_hand = torch.matmul(
71 parent_rots.reshape(-1, 3, 3).transpose(1, 2),
72 wrist_pose_from_hand.reshape(-1, 3, 3))
73
74 right_hand_wrist = wrist_pose_from_hand[right_hand_from_body_idxs]
75 left_hand_wrist = flip_rotmat(
76 wrist_pose_from_hand[left_hand_from_body_idxs])
77 right_hand_pose = hand_predictions['pred_param']['right_hand_pose'][
78 right_hand_from_body_idxs]
79 left_hand_pose = flip_rotmat(
80 hand_predictions['pred_param']['right_hand_pose']
81 [left_hand_from_body_idxs])
82
83 body_predictions['pred_param']['right_hand_pose'] = right_hand_pose
84 body_predictions['pred_param']['left_hand_pose'] = left_hand_pose
85 body_predictions['pred_param']['body_pose'][:, self.right_wrist_idx -
86 1] = right_hand_wrist
87 body_predictions['pred_param']['body_pose'][:, self.left_wrist_idx -
88 1] = left_hand_wrist
89
90 return body_predictions
91
92

Callers

nothing calls this directly

Calls 2

flip_rotmatFunction · 0.85

Tested by

no test coverage detected