Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions mmpose/evaluation/metrics/keypoint_3d_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ class MPJPE(BaseMetric):
Note:
- length of dataset: N
- num_keypoints: K
- number of keypoint dimensions: D (typically D = 2)
- number of keypoint dimensions: D (typically D = 3)

Args:
mode (str): Method to align the prediction with the
ground truth. Supported options are:

- ``'mpjpe'``: no alignment will be applied
- ``'p-mpjpe'``: align in the least-square sense in scale
- ``'n-mpjpe'``: align in the least-square sense in
scale, rotation, and translation.
- ``'p-mpjpe'``: align in the least-square sense in scale,
rotation, and translation.
- ``'n-mpjpe'``: align in the least-square sense in scale.

collect_device (str): Device name used for collecting results from
different ranks during distributed training. Must be ``'cpu'`` or
Expand Down Expand Up @@ -79,7 +79,7 @@ def process(self, data_batch: Sequence[dict],
gt = data_sample['gt_instances']
# ground truth keypoints coordinates, [T, K, D]
gt_coords = gt['lifting_target']
# ground truth keypoints_visible, [T, K, 1]
# ground truth keypoints_visible, [T, K]
mask = gt['lifting_target_visible'].astype(bool).reshape(
gt_coords.shape[0], -1)
# instance action
Expand Down
18 changes: 7 additions & 11 deletions mmpose/evaluation/metrics/simple_keypoint_3d_metrics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (c) OpenMMLab. All rights reserved.
from typing import Dict, List, Optional, Sequence
from typing import Dict, Optional, Sequence

import numpy as np
from mmengine.evaluator import BaseMetric
Expand All @@ -18,16 +18,16 @@ class SimpleMPJPE(BaseMetric):
Note:
- length of dataset: N
- num_keypoints: K
- number of keypoint dimensions: D (typically D = 2)
- number of keypoint dimensions: D (typically D = 3)

Args:
mode (str): Method to align the prediction with the
ground truth. Supported options are:

- ``'mpjpe'``: no alignment will be applied
- ``'p-mpjpe'``: align in the least-square sense in scale
- ``'n-mpjpe'``: align in the least-square sense in
scale, rotation, and translation.
- ``'p-mpjpe'``: align in the least-square sense in scale,
rotation, and translation.
- ``'n-mpjpe'``: align in the least-square sense in scale.

collect_device (str): Device name used for collecting results from
different ranks during distributed training. Must be ``'cpu'`` or
Expand All @@ -36,25 +36,21 @@ class SimpleMPJPE(BaseMetric):
names to disambiguate homonymous metrics of different evaluators.
If prefix is not provided in the argument, ``self.default_prefix``
will be used instead. Default: ``None``.
skip_list (list, optional): The list of subject and action combinations
to be skipped. Default: [].
"""

ALIGNMENT = {'mpjpe': 'none', 'p-mpjpe': 'procrustes', 'n-mpjpe': 'scale'}

def __init__(self,
mode: str = 'mpjpe',
collect_device: str = 'cpu',
prefix: Optional[str] = None,
skip_list: List[str] = []) -> None:
prefix: Optional[str] = None) -> None:
super().__init__(collect_device=collect_device, prefix=prefix)
allowed_modes = self.ALIGNMENT.keys()
if mode not in allowed_modes:
raise KeyError("`mode` should be 'mpjpe', 'p-mpjpe', or "
f"'n-mpjpe', but got '{mode}'.")

self.mode = mode
self.skip_list = skip_list

def process(self, data_batch: Sequence[dict],
data_samples: Sequence[dict]) -> None:
Expand All @@ -77,7 +73,7 @@ def process(self, data_batch: Sequence[dict],
gt = data_sample['gt_instances']
# ground truth keypoints coordinates, [T, K, D]
gt_coords = gt['lifting_target']
# ground truth keypoints_visible, [T, K, 1]
# ground truth keypoints_visible, [T, K]
mask = gt['lifting_target_visible'].astype(bool).reshape(
gt_coords.shape[0], -1)

Expand Down