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

Method __call__

detrsmpl/models/utils/SMPLX.py:617–669  ·  view source on GitHub ↗

Function Args: body_predictions (dict): The prediction from body model. img_metas (dict): Information of the input images. Returns: all_face_imgs (torch.tensor): Cropped face images. face_mean (torch.tensor): Mean value of face params.

(self, body_predictions, img_metas)

Source from the content-addressed store, hash-verified

615 return face_mean
616
617 def __call__(self, body_predictions, img_metas):
618 """Function
619 Args:
620 body_predictions (dict): The prediction from body model.
621 img_metas (dict): Information of the input images.
622 Returns:
623 all_face_imgs (torch.tensor): Cropped face images.
624 face_mean (torch.tensor): Mean value of face params.
625 crop_info (dict): Face crop transforms.
626 """
627 pred_param = body_predictions['pred_param']
628 pred_cam = body_predictions['pred_cam']
629 pred_raw = body_predictions['pred_raw']
630
631 pred_output = self.body_model(**pred_param)
632
633 pred_keypoints3d = pred_output['joints']
634 pred_keypoints2d = weak_perspective_projection(
635 pred_keypoints3d,
636 scale=pred_cam[:, 0],
637 translation=pred_cam[:, 1:3])
638 # concat ori_img
639 full_images = []
640 for img_meta in img_metas:
641 full_images.append(img_meta['ori_img'].to(device=pred_cam.device))
642 full_imgs = concat_images(full_images)
643
644 face_joints = (pred_keypoints2d[:, self.face_idx] * 0.5 +
645 0.5) * (self.img_res - 1)
646 face_points_to_crop = get_crop_info(face_joints, img_metas,
647 self.scale_factor, self.img_res)
648 face_center = face_points_to_crop['center']
649 face_orig_bbox_size = face_points_to_crop['orig_bbox_size']
650 face_inv_crop_transforms = face_points_to_crop['inv_crop_transforms']
651
652 face_cropper_out = self.face_cropper(full_imgs, face_center,
653 face_orig_bbox_size)
654 face_crops = face_cropper_out['images']
655 # face_points = face_cropper_out['sampling_grid']
656 face_crop_transform = face_cropper_out['transform']
657
658 all_face_imgs = [face_crops]
659 all_face_imgs = torch.cat(all_face_imgs, dim=0)
660
661 face_mean = self.build_face_mean(pred_param['global_orient'],
662 pred_param['body_pose'],
663 pred_param['betas'],
664 pred_raw['raw_jaw_pose'],
665 pred_param['expression'],
666 batch_size=full_imgs.shape[0])
667 crop_info = dict(face_inv_crop_transforms=face_inv_crop_transforms,
668 face_crop_transform=face_crop_transform)
669 return all_face_imgs, face_mean, crop_info

Callers

nothing calls this directly

Calls 5

build_face_meanMethod · 0.95
concat_imagesFunction · 0.85
get_crop_infoFunction · 0.85
toMethod · 0.45

Tested by

no test coverage detected