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

Method build_face_mean

detrsmpl/models/utils/SMPLX.py:566–615  ·  view source on GitHub ↗

Builds the initial point for the iterative regressor of the face.

(self, global_orient, body_pose, betas, raw_jaw_pose,
                        expression, batch_size)

Source from the content-addressed store, hash-verified

564 self.face_cropper = CropSampler(crop_size)
565
566 def build_face_mean(self, global_orient, body_pose, betas, raw_jaw_pose,
567 expression, batch_size):
568 """Builds the initial point for the iterative regressor of the face."""
569 face_mean = []
570 # Compute the absolute pose of the right wrist
571 neck_pose_abs = find_joint_global_rotation(self.neck_kin_chain,
572 global_orient, body_pose)
573 # Convert the absolute neck pose to offsets
574 neck_pose = neck_pose_abs[:, :3, :2].contiguous().reshape(
575 batch_size, -1)
576
577 camera_mean = self.model_head.get_mean('camera', batch_size=batch_size)
578
579 neck_pose_condition = (neck_pose if self.condition_face_neck_pose else
580 self.model_head.get_mean('global_orient',
581 batch_size=batch_size))
582
583 jaw_pose_condition = (raw_jaw_pose.reshape(batch_size, -1)
584 if self.condition_face_jaw_pose else
585 self.model_head.get_mean('jaw_pose',
586 batch_size=batch_size))
587 face_num_betas = self.model_head.get_num_betas()
588 shape_padding_size = face_num_betas - self.num_betas
589 betas_condition = (
590 F.pad(betas.reshape(batch_size, -1),
591 (0, shape_padding_size)) if self.condition_face_shape else
592 self.model_head.get_mean('shape', batch_size=batch_size))
593
594 face_num_expression_coeffs = self.model_head.get_num_expression_coeffs(
595 )
596 expr_padding_size = face_num_expression_coeffs \
597 - self.num_expression_coeffs
598 expression_condition = (
599 F.pad(expression.reshape(batch_size, -1),
600 (0, expr_padding_size)) if self.condition_face_expression
601 else self.model_head.get_mean('expression', batch_size=batch_size))
602
603 # Should be Bx(Head pose params)
604 face_mean.append(
605 torch.cat([
606 neck_pose_condition,
607 jaw_pose_condition,
608 betas_condition,
609 expression_condition,
610 camera_mean.reshape(batch_size, -1),
611 ],
612 dim=1))
613
614 face_mean = torch.cat(face_mean, dim=0)
615 return face_mean
616
617 def __call__(self, body_predictions, img_metas):
618 """Function

Callers 1

__call__Method · 0.95

Calls 4

get_num_betasMethod · 0.80
get_meanMethod · 0.45

Tested by

no test coverage detected