diff --git a/mmhuman3d/models/body_models/mano.py b/mmhuman3d/models/body_models/mano.py index f9bd363f..426fef87 100644 --- a/mmhuman3d/models/body_models/mano.py +++ b/mmhuman3d/models/body_models/mano.py @@ -7,6 +7,7 @@ convert_kps, get_keypoint_num, ) +from mmhuman3d.utils.transforms import aa_to_rotmat, rotmat_to_aa class MANO(_MANO): @@ -203,6 +204,7 @@ def __init__(self, self.num_verts = self.get_num_verts() self.num_faces = self.get_num_faces() self.num_joints = get_keypoint_num(convention=self.keypoint_dst) + self.flat_hand_mean = kwargs['flat_hand_mean'] def forward(self, *args, @@ -222,6 +224,12 @@ def forward(self, """ if 'right_hand_pose' in kwargs: kwargs['hand_pose'] = kwargs['right_hand_pose'] + + if not self.flat_hand_mean: + right_hand_pose = rotmat_to_aa(kwargs['right_hand_pose']) + right_hand_pose = right_hand_pose + self.hand_mean.reshape(-1, 3) + kwargs['hand_pose'] = aa_to_rotmat(right_hand_pose) + mano_output = super(MANOLayer, self).forward(*args, **kwargs) joints = mano_output.joints diff --git a/mmhuman3d/models/body_models/smplx.py b/mmhuman3d/models/body_models/smplx.py index 55d829dc..42e21559 100644 --- a/mmhuman3d/models/body_models/smplx.py +++ b/mmhuman3d/models/body_models/smplx.py @@ -11,6 +11,7 @@ get_keypoint_num, ) from mmhuman3d.core.conventions.segmentation import body_segmentation +from mmhuman3d.utils.transforms import aa_to_rotmat, rotmat_to_aa class SMPLX(_SMPLX): @@ -315,6 +316,7 @@ def __init__(self, self.num_verts = self.get_num_verts() self.num_joints = get_keypoint_num(convention=self.keypoint_dst) self.body_part_segmentation = body_segmentation('smplx') + self.flat_hand_mean = kwargs['flat_hand_mean'] def forward(self, *args, @@ -333,6 +335,17 @@ def forward(self, output: contains output parameters and attributes """ + if not self.flat_hand_mean: + right_hand_pose = rotmat_to_aa(kwargs['right_hand_pose']) + right_hand_pose = right_hand_pose + self.right_hand_mean.reshape( + -1, 3) + kwargs['right_hand_pose'] = aa_to_rotmat(right_hand_pose) + + left_hand_pose = rotmat_to_aa(kwargs['left_hand_pose']) + left_hand_pose = left_hand_pose + self.left_hand_mean.reshape( + -1, 3) + kwargs['left_hand_pose'] = aa_to_rotmat(left_hand_pose) + kwargs['get_skin'] = True smplx_output = super(SMPLXLayer, self).forward(*args, **kwargs)