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

Method forward

detrsmpl/models/body_models/smpl.py:486–610  ·  view source on GitHub ↗

Inverse pass for the SMPL model. Args: pose_skeleton: torch.tensor, optional, shape Bx(J*3) It should be a tensor that contains joint locations in (img, Y, Z) format. (default=None) betas: torch.tensor, optional, shape Bx10

(self,
                pose_skeleton,
                betas,
                phis,
                global_orient,
                transl=None,
                return_verts=True,
                leaf_thetas=None)

Source from the content-addressed store, hash-verified

484 return children
485
486 def forward(self,
487 pose_skeleton,
488 betas,
489 phis,
490 global_orient,
491 transl=None,
492 return_verts=True,
493 leaf_thetas=None):
494 """Inverse pass for the SMPL model.
495
496 Args:
497 pose_skeleton: torch.tensor, optional, shape Bx(J*3)
498 It should be a tensor that contains joint locations in
499 (img, Y, Z) format. (default=None)
500 betas: torch.tensor, optional, shape Bx10
501 It can used if shape parameters
502 `betas` are predicted from some external model.
503 (default=None)
504 phis: torch.tensor, shape Bx23x2
505 Rotation on bone axis parameters
506 global_orient: torch.tensor, optional, shape Bx3
507 Global Orientations.
508 transl: torch.tensor, optional, shape Bx3
509 Global Translations.
510 return_verts: bool, optional
511 Return the vertices. (default=True)
512 leaf_thetas: torch.tensor, optional, shape Bx5x4
513 Quaternions of 5 leaf joints. (default=None)
514
515 Returns
516 outputs: output dictionary.
517 """
518 batch_size = pose_skeleton.shape[0]
519
520 if leaf_thetas is not None:
521 leaf_thetas = leaf_thetas.reshape(batch_size * 5, 4)
522 leaf_thetas = quat_to_rotmat(leaf_thetas)
523
524 batch_size = max(betas.shape[0], pose_skeleton.shape[0])
525 device = betas.device
526
527 # 1. Add shape contribution
528 v_shaped = self.v_template + blend_shapes(betas, self.shapedirs)
529
530 # 2. Get the rest joints
531 # NxJx3 array
532 if leaf_thetas is not None:
533 rest_J = vertices2joints(self.J_regressor, v_shaped)
534 else:
535 rest_J = torch.zeros((v_shaped.shape[0], 29, 3),
536 dtype=self.dtype,
537 device=device)
538 rest_J[:, :24] = vertices2joints(self.J_regressor, v_shaped)
539
540 leaf_number = [411, 2445, 5905, 3216, 6617]
541 leaf_vertices = v_shaped[:, leaf_number].clone()
542 rest_J[:, 24:] = leaf_vertices
543

Callers

nothing calls this directly

Calls 7

quat_to_rotmatFunction · 0.90
blend_shapesFunction · 0.90
vertices2jointsFunction · 0.90
batch_rigid_transformFunction · 0.90
cloneMethod · 0.80
detachMethod · 0.45

Tested by

no test coverage detected