Forward pass for the STAR model. Args: global_orient: torch.tensor, optional, shape Bx3 Global orientation (rotation) of the body. If given, ignore the member variable and use it as the global rotation of the body. Useful if someon
(self,
global_orient: Optional[torch.Tensor] = None,
body_pose: Optional[torch.Tensor] = None,
betas: Optional[torch.Tensor] = None,
transl: Optional[torch.Tensor] = None,
return_verts: bool = True,
return_full_pose: bool = True)
| 213 | self.R = None |
| 214 | |
| 215 | def forward(self, |
| 216 | global_orient: Optional[torch.Tensor] = None, |
| 217 | body_pose: Optional[torch.Tensor] = None, |
| 218 | betas: Optional[torch.Tensor] = None, |
| 219 | transl: Optional[torch.Tensor] = None, |
| 220 | return_verts: bool = True, |
| 221 | return_full_pose: bool = True) -> torch.Tensor: |
| 222 | """Forward pass for the STAR model. |
| 223 | |
| 224 | Args: |
| 225 | global_orient: torch.tensor, optional, shape Bx3 |
| 226 | Global orientation (rotation) of the body. If given, ignore the |
| 227 | member variable and use it as the global rotation of the body. |
| 228 | Useful if someone wishes to predicts this with an external |
| 229 | model. (default=None) |
| 230 | body_pose: torch.Tensor, shape Bx(J*3) |
| 231 | Pose parameters for the STAR model. It should be a tensor that |
| 232 | contains joint rotations in axis-angle format. If given, ignore |
| 233 | the member variable and use it as the body parameters. |
| 234 | (default=None) |
| 235 | betas: torch.Tensor, shape Bx10 |
| 236 | Shape parameters for the STAR model. If given, ignore the |
| 237 | member variable and use it as shape parameters. (default=None) |
| 238 | transl: torch.Tensor, shape Bx3 |
| 239 | Translation vector for the STAR model. If given, ignore the |
| 240 | member variable and use it as the translation of the body. |
| 241 | (default=None) |
| 242 | Returns: |
| 243 | output: Contains output parameters and attributes corresponding |
| 244 | to other body models. |
| 245 | """ |
| 246 | global_orient = (global_orient |
| 247 | if global_orient is not None else self.global_orient) |
| 248 | body_pose = body_pose if body_pose is not None else self.body_pose |
| 249 | betas = betas if betas is not None else self.betas |
| 250 | apply_transl = transl is not None or hasattr(self, 'transl') |
| 251 | if transl is None and hasattr(self, 'transl'): |
| 252 | transl = self.transl |
| 253 | |
| 254 | batch_size = body_pose.shape[0] |
| 255 | v_template = self.v_template[None, :] |
| 256 | shapedirs = self.shapedirs.view(-1, self.num_betas)[None, :].expand( |
| 257 | batch_size, -1, -1) |
| 258 | beta = betas[:, :, None] |
| 259 | v_shaped = torch.matmul(shapedirs, beta).view(-1, 6890, 3) + v_template |
| 260 | J = torch.einsum('bik,ji->bjk', [v_shaped, self.J_regressor]) |
| 261 | |
| 262 | pose_quat = self.normalize_quaternion(body_pose.view(-1, 3)).view( |
| 263 | batch_size, -1) |
| 264 | pose_feat = torch.cat((pose_quat[:, 4:], beta[:, 1]), 1) |
| 265 | |
| 266 | R = aa_to_rotmat(body_pose.view(-1, 3)).view(batch_size, 24, 3, 3) |
| 267 | R = R.view(batch_size, 24, 3, 3) |
| 268 | |
| 269 | posedirs = self.posedirs[None, :].expand(batch_size, -1, -1) |
| 270 | v_posed = v_shaped + torch.matmul( |
| 271 | posedirs, pose_feat[:, :, None]).view(-1, 6890, 3) |
| 272 |
nothing calls this directly
no test coverage detected