Function Args: body_predictions (dict): The prediction from body model. img_metas (dict): Information of the input images. Returns: all_hand_imgs (torch.tensor): Cropped hand images. hand_mean (torch.tensor): Mean value of hand params.
(self, body_predictions, img_metas)
| 445 | return hand_mean |
| 446 | |
| 447 | def __call__(self, body_predictions, img_metas): |
| 448 | """Function |
| 449 | Args: |
| 450 | body_predictions (dict): The prediction from body model. |
| 451 | img_metas (dict): Information of the input images. |
| 452 | Returns: |
| 453 | all_hand_imgs (torch.tensor): Cropped hand images. |
| 454 | hand_mean (torch.tensor): Mean value of hand params. |
| 455 | crop_info (dict): Hand crop transforms. |
| 456 | """ |
| 457 | pred_param = body_predictions['pred_param'] |
| 458 | pred_cam = body_predictions['pred_cam'] |
| 459 | pred_raw = body_predictions['pred_raw'] |
| 460 | pred_output = self.body_model(**pred_param) |
| 461 | |
| 462 | pred_keypoints3d = pred_output['joints'] |
| 463 | pred_keypoints2d = weak_perspective_projection( |
| 464 | pred_keypoints3d, |
| 465 | scale=pred_cam[:, 0], |
| 466 | translation=pred_cam[:, 1:3]) |
| 467 | # concat ori_img |
| 468 | full_images = [] |
| 469 | for img_meta in img_metas: |
| 470 | full_images.append(img_meta['ori_img'].to(device=pred_cam.device)) |
| 471 | full_imgs = concat_images(full_images) |
| 472 | |
| 473 | # left hand |
| 474 | left_hand_joints = (pred_keypoints2d[:, self.left_hand_idxs] * 0.5 + |
| 475 | 0.5) * (self.img_res - 1) |
| 476 | left_hand_points_to_crop = get_crop_info(left_hand_joints, img_metas, |
| 477 | self.scale_factor, |
| 478 | self.img_res) |
| 479 | left_hand_center = left_hand_points_to_crop['center'] |
| 480 | left_hand_orig_bbox_size = left_hand_points_to_crop['orig_bbox_size'] |
| 481 | left_hand_inv_crop_transforms = left_hand_points_to_crop[ |
| 482 | 'inv_crop_transforms'] |
| 483 | |
| 484 | left_hand_cropper_out = self.hand_cropper(full_imgs, left_hand_center, |
| 485 | left_hand_orig_bbox_size) |
| 486 | left_hand_crops = left_hand_cropper_out['images'] |
| 487 | # left_hand_points = left_hand_cropper_out['sampling_grid'] |
| 488 | left_hand_crop_transform = left_hand_cropper_out['transform'] |
| 489 | |
| 490 | # right hand |
| 491 | right_hand_joints = (pred_keypoints2d[:, self.right_hand_idxs] * 0.5 + |
| 492 | 0.5) * (self.img_res - 1) |
| 493 | right_hand_points_to_crop = get_crop_info(right_hand_joints, img_metas, |
| 494 | self.scale_factor, |
| 495 | self.img_res) |
| 496 | right_hand_center = right_hand_points_to_crop['center'] |
| 497 | right_hand_orig_bbox_size = right_hand_points_to_crop['orig_bbox_size'] |
| 498 | # right_hand_inv_crop_transforms = right_hand_points_to_crop[ |
| 499 | # 'inv_crop_transforms'] |
| 500 | right_hand_cropper_out = self.hand_cropper(full_imgs, |
| 501 | right_hand_center, |
| 502 | right_hand_orig_bbox_size) |
| 503 | right_hand_crops = right_hand_cropper_out['images'] |
| 504 | # right_hand_points = right_hand_cropper_out['sampling_grid'] |
nothing calls this directly
no test coverage detected