Generate the target heatmap. Required keys: 'joints_3d', 'joints_3d_visible', 'ann_info'. Modified keys: 'target', and 'target_weight'. Args: sigma: Sigma of heatmap gaussian for 'MSRA' approach. kernel: Kernel of heatmap gaussian for 'Megvii' approach. encoding (
| 484 | |
| 485 | |
| 486 | class TopDownGenerateTarget: |
| 487 | """Generate the target heatmap. |
| 488 | Required keys: 'joints_3d', 'joints_3d_visible', 'ann_info'. |
| 489 | Modified keys: 'target', and 'target_weight'. |
| 490 | Args: |
| 491 | sigma: Sigma of heatmap gaussian for 'MSRA' approach. |
| 492 | kernel: Kernel of heatmap gaussian for 'Megvii' approach. |
| 493 | encoding (str): Approach to generate target heatmaps. |
| 494 | Currently supported approaches: 'MSRA', 'Megvii', 'UDP'. |
| 495 | Default:'MSRA' |
| 496 | unbiased_encoding (bool): Option to use unbiased |
| 497 | encoding methods. |
| 498 | Paper ref: Zhang et al. Distribution-Aware Coordinate |
| 499 | Representation for Human Pose Estimation (CVPR 2020). |
| 500 | keypoint_pose_distance: Keypoint pose distance for UDP. |
| 501 | Paper ref: Huang et al. The Devil is in the Details: Delving into |
| 502 | Unbiased Data Processing for Human Pose Estimation (CVPR 2020). |
| 503 | target_type (str): supported targets: 'GaussianHeatmap', |
| 504 | 'CombinedTarget'. Default:'GaussianHeatmap' |
| 505 | CombinedTarget: The combination of classification target |
| 506 | (response map) and regression target (offset map). |
| 507 | Paper ref: Huang et al. The Devil is in the Details: Delving into |
| 508 | Unbiased Data Processing for Human Pose Estimation (CVPR 2020). |
| 509 | """ |
| 510 | |
| 511 | def __init__(self, |
| 512 | sigma=2, |
| 513 | kernel=(11, 11), |
| 514 | valid_radius_factor=0.0546875, |
| 515 | target_type='GaussianHeatmap', |
| 516 | encoding='MSRA', |
| 517 | unbiased_encoding=False): |
| 518 | self.sigma = sigma |
| 519 | self.unbiased_encoding = unbiased_encoding |
| 520 | self.kernel = kernel |
| 521 | self.valid_radius_factor = valid_radius_factor |
| 522 | self.target_type = target_type |
| 523 | self.encoding = encoding |
| 524 | |
| 525 | def _msra_generate_target(self, cfg, joints_3d, joints_3d_visible, sigma): |
| 526 | """Generate the target heatmap via "MSRA" approach. |
| 527 | Args: |
| 528 | cfg (dict): data config |
| 529 | joints_3d: np.ndarray ([num_joints, 3]) |
| 530 | joints_3d_visible: np.ndarray ([num_joints, 3]) |
| 531 | sigma: Sigma of heatmap gaussian |
| 532 | Returns: |
| 533 | tuple: A tuple containing targets. |
| 534 | - target: Target heatmaps. |
| 535 | - target_weight: (1: visible, 0: invisible) |
| 536 | """ |
| 537 | num_joints = cfg['num_joints'] |
| 538 | image_size = cfg['image_size'] |
| 539 | W, H = cfg['heatmap_size'] |
| 540 | joint_weights = cfg['joint_weights'] |
| 541 | use_different_joint_weights = cfg['use_different_joint_weights'] |
| 542 | |
| 543 | target_weight = np.zeros((num_joints, 1), dtype=np.float32) |