Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Add COCOPoseMetric #97

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

LareinaM
Copy link
Contributor

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

Add COCOPoseMetric for pose estimation task.

PR in mmpose: open-mmlab/mmpose#1777, about the results verification.

Modification

  1. Add COCOPoseMetric under mmeval/metrics/coco_pose.py.
  2. Add some test data: tests/test_metrics/data/coco_pose_sample.json, tests/test_metrics/data/crowdpose_sample.json, tests/test_metrics/data/ap10k_sample.json and unit tests.
  3. Add nms function under mmeval/metrics/utils/nms.py.

BC-breaking (Optional)

Does the modification introduce changes that break the backward-compatibility of the downstream repos?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.

Use cases (Optional)

If this PR introduces a new feature, it is better to list some use cases here, and update the documentation.

Checklist

  1. Pre-commit or other linting tools are used to fix the potential lint issues.
  2. The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  3. If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDet or MMCls.
  4. The documentation has been modified accordingly, like docstring or example tutorials.

Comments

  1. Change of examples in mmeval/metrics/coco_pose.py: add case and simplify input
  2. Fix all formats and typos
  3. add function aims at keeping consistent with that of COCODetection, and after discussion, no modification is made
  4. Indents in the files are implied by yapf hook

mmeval/metrics/coco_pose.py Outdated Show resolved Hide resolved
mmeval/metrics/coco_pose.py Outdated Show resolved Hide resolved
mmeval/metrics/coco_pose.py Outdated Show resolved Hide resolved
mmeval/metrics/coco_pose.py Outdated Show resolved Hide resolved
mmeval/metrics/coco_pose.py Show resolved Hide resolved
mmeval/metrics/coco_pose.py Outdated Show resolved Hide resolved
self.format_only = format_only
self.outfile_prefix = outfile_prefix

def add(self, predictions: Sequence[Dict], groundtruths: Sequence[Dict]) -> None: # type: ignore # yapf: disable # noqa: E501
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about making groundtruths defaults to None so that it's easier for users to use it with ann_file != None? Creating an 'empty' groundtruths is ambiguous and inconvenient, since we require it has the same length as predictions

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be some new design or discussions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our thoughts were to keep consistent with that of COCODetection, maybe this needs further discussions with the team.

- `num_keypoints`: it is necessary when
`self.iou_type` is set as `keypoints_crowd`.
"""
for prediction, groundtruth in zip(predictions, groundtruths):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

predictions is instance-level while groundtruths is image-level. Usually they are of different length, i.e. N predictions in 1 image. How to make them of the same length? I think the design of input type is not reasonable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

I think the developer assumed both to be of instance-level. Also can be inferred from the unit test.

image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the meaning of id in predictions? Is there only 1 instance in each image, or there might be multiple instances in an image? How to match your detections with groundtruths without knowing the groundtruths, i.e. same number of detections as groundtruths?

I'm not familiar with the format, but seems like raw_ann_info in groundtruth covers all instances' labels in a single image. Please clarify if I misunderstood.

Copy link
Contributor Author

@LareinaM LareinaM Feb 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be multiple instances in an image. For example, in coco_pose_sample.json, there are three entries with "image_id": 40083, because in the image, there are three people. The three instances have different and unique ids.

In compute_metric, groundtruths (a list of groundtruth instances) are represented by a COCO format json file, while predicted instances of the same image are grouped together and dumped into another json file. The evaluation results are calculated by COCOeval by reading the above two files.

Each ann (raw_ann_info) represents an instance, with information of the groundtruth keypoints and bboxes, etc.

mmeval/metrics/coco_pose.py Outdated Show resolved Hide resolved
mmeval/metrics/coco_pose.py Show resolved Hide resolved
@C1rN09 C1rN09 mentioned this pull request Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants