Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Add return arguments for SMPLify-X #211

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion mmhuman3d/models/registrants/smplifyx.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ def __call__(self,
**stage_config,
)

return {
# collate results
ret = {
'global_orient': global_orient,
'transl': transl,
'body_pose': body_pose,
Expand All @@ -142,6 +143,46 @@ def __call__(self,
'reye_pose': reye_pose
}

if return_verts or return_joints or \
return_full_pose or return_losses:
eval_ret = self.evaluate(
global_orient=global_orient,
transl=transl,
body_pose=body_pose,
betas=betas,
left_hand_pose=left_hand_pose,
right_hand_pose=right_hand_pose,
expression=expression,
jaw_pose=jaw_pose,
leye_pose=leye_pose,
reye_pose=reye_pose,
keypoints2d=keypoints2d,
keypoints2d_conf=keypoints2d_conf,
keypoints3d=keypoints3d,
keypoints3d_conf=keypoints3d_conf,
return_verts=return_verts,
return_full_pose=return_full_pose,
return_joints=return_joints,
reduction_override='none' # sample-wise loss
)

if return_verts:
ret['vertices'] = eval_ret['vertices']
if return_joints:
ret['joints'] = eval_ret['joints']
if return_full_pose:
ret['full_pose'] = eval_ret['full_pose']
if return_losses:
for k in eval_ret.keys():
if 'loss' in k:
ret[k] = eval_ret[k]

for k, v in ret.items():
if isinstance(v, torch.Tensor):
ret[k] = v.detach().clone()

return ret

def _optimize_stage(self,
betas: torch.Tensor,
body_pose: torch.Tensor,
Expand Down