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

Method forward

util/smplx/smplx/body_models.py:658–724  ·  view source on GitHub ↗
(self,
                betas: Optional[Tensor] = None,
                global_orient: Optional[Tensor] = None,
                body_pose: Optional[Tensor] = None,
                left_hand_pose: Optional[Tensor] = None,
                right_hand_pose: Optional[Tensor] = None,
                transl: Optional[Tensor] = None,
                return_verts: bool = True,
                return_full_pose: bool = False,
                pose2rot: bool = True,
                **kwargs)

Source from the content-addressed store, hash-verified

656 return '\n'.join(msg)
657
658 def forward(self,
659 betas: Optional[Tensor] = None,
660 global_orient: Optional[Tensor] = None,
661 body_pose: Optional[Tensor] = None,
662 left_hand_pose: Optional[Tensor] = None,
663 right_hand_pose: Optional[Tensor] = None,
664 transl: Optional[Tensor] = None,
665 return_verts: bool = True,
666 return_full_pose: bool = False,
667 pose2rot: bool = True,
668 **kwargs) -> SMPLHOutput:
669 """"""
670 # If no shape and pose parameters are passed along, then use the
671 # ones from the module
672 global_orient = (global_orient
673 if global_orient is not None else self.global_orient)
674 body_pose = body_pose if body_pose is not None else self.body_pose
675 betas = betas if betas is not None else self.betas
676 left_hand_pose = (left_hand_pose if left_hand_pose is not None else
677 self.left_hand_pose)
678 right_hand_pose = (right_hand_pose if right_hand_pose is not None else
679 self.right_hand_pose)
680
681 apply_trans = transl is not None or hasattr(self, 'transl')
682 if transl is None:
683 if hasattr(self, 'transl'):
684 transl = self.transl
685
686 if self.use_pca:
687 left_hand_pose = torch.einsum(
688 'bi,ij->bj', [left_hand_pose, self.left_hand_components])
689 right_hand_pose = torch.einsum(
690 'bi,ij->bj', [right_hand_pose, self.right_hand_components])
691
692 full_pose = torch.cat(
693 [global_orient, body_pose, left_hand_pose, right_hand_pose], dim=1)
694 full_pose += self.pose_mean
695
696 vertices, joints = lbs(self.betas,
697 full_pose,
698 self.v_template,
699 self.shapedirs,
700 self.posedirs,
701 self.J_regressor,
702 self.parents,
703 self.lbs_weights,
704 pose2rot=pose2rot)
705
706 # Add any extra joints that might be needed
707 joints = self.vertex_joint_selector(vertices, joints)
708 if self.joint_mapper is not None:
709 joints = self.joint_mapper(joints)
710
711 if apply_trans:
712 joints += transl.unsqueeze(dim=1)
713 vertices += transl.unsqueeze(dim=1)
714
715 output = SMPLHOutput(vertices=vertices if return_verts else None,

Callers

nothing calls this directly

Calls 2

lbsFunction · 0.90
SMPLHOutputClass · 0.85

Tested by

no test coverage detected