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

Method forward

util/smplx/smplx/body_models.py:1556–1613  ·  view source on GitHub ↗

Forward pass for the MANO model.

(self,
                betas: Optional[Tensor] = None,
                global_orient: Optional[Tensor] = None,
                hand_pose: Optional[Tensor] = None,
                transl: Optional[Tensor] = None,
                return_verts: bool = True,
                return_full_pose: bool = False,
                **kwargs)

Source from the content-addressed store, hash-verified

1554 return '\n'.join(msg)
1555
1556 def forward(self,
1557 betas: Optional[Tensor] = None,
1558 global_orient: Optional[Tensor] = None,
1559 hand_pose: Optional[Tensor] = None,
1560 transl: Optional[Tensor] = None,
1561 return_verts: bool = True,
1562 return_full_pose: bool = False,
1563 **kwargs) -> MANOOutput:
1564 """Forward pass for the MANO model."""
1565 # If no shape and pose parameters are passed along, then use the
1566 # ones from the module
1567 global_orient = (global_orient
1568 if global_orient is not None else self.global_orient)
1569 betas = betas if betas is not None else self.betas
1570 hand_pose = (hand_pose if hand_pose is not None else self.hand_pose)
1571
1572 apply_trans = transl is not None or hasattr(self, 'transl')
1573 if transl is None:
1574 if hasattr(self, 'transl'):
1575 transl = self.transl
1576
1577 if self.use_pca:
1578 hand_pose = torch.einsum('bi,ij->bj',
1579 [hand_pose, self.hand_components])
1580
1581 full_pose = torch.cat([global_orient, hand_pose], dim=1)
1582 full_pose += self.pose_mean
1583
1584 vertices, joints = lbs(
1585 betas,
1586 full_pose,
1587 self.v_template,
1588 self.shapedirs,
1589 self.posedirs,
1590 self.J_regressor,
1591 self.parents,
1592 self.lbs_weights,
1593 pose2rot=True,
1594 )
1595
1596 # # Add pre-selected extra joints that might be needed
1597 # joints = self.vertex_joint_selector(vertices, joints)
1598
1599 if self.joint_mapper is not None:
1600 joints = self.joint_mapper(joints)
1601
1602 if apply_trans:
1603 joints = joints + transl.unsqueeze(dim=1)
1604 vertices = vertices + transl.unsqueeze(dim=1)
1605
1606 output = MANOOutput(vertices=vertices if return_verts else None,
1607 joints=joints if return_verts else None,
1608 betas=betas,
1609 global_orient=global_orient,
1610 hand_pose=hand_pose,
1611 full_pose=full_pose if return_full_pose else None)
1612
1613 return output

Callers

nothing calls this directly

Calls 2

lbsFunction · 0.90
MANOOutputClass · 0.85

Tested by

no test coverage detected