[Feature] Support evaluating CocoMetric without ann_file. #1722
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Support evaluating coco metric without ann_file thus other non-COCO format datasets can take CocoMetric as well.
Modification
'CLASSES'
in the dataset metainfo to store the information about category.'raw_ann_info'
key in the definition ofBaseCocoStyleDataset
'raw_ann_info'
key inmmpose/datasets/transforms/formatting.py
CocoMetric
, addgt_to_coco_json
function. Also fix the inheritance dependency ofPoseTrack18Metric
BC-breaking (Optional)
Use cases (Optional)
In order to use this function, we need to change some places:
'raw_ann_info'
to the data_info in the dataset to store the raw annotation information:'ann_file'
in CocoMetric:Verification
I have tested on these following datasets and the results are exactly the same:
Comment some codes of
mmpose/datasets/datasets/base/base_coco_style_dataset.py
to omit the filtering:gt_bbox
, because can not assign gtkeypoints
andbboxes
information to each detection bbox. Besides, the filtering condition should be deleted, so that each gt instance will be inferenced. Under these conditions, the results with and without ann_file are exactly the same (with 11004 samples in total, which is equal to the number of samples before filtering).Test command:
With ann_file:
Without ann_file:
Test command:
With ann_file:
Without ann_file:
_do_python_keypoint_eval
function inCocoMetric
.Can only evaluate
gt_bbox
, because can not assign gtkeypoints
andbboxes
information to each detection bbox. Besides, the filtering condition should be deleted, so that each gt instance will be inferenced. Under these conditions, the results with and without ann_file are exactly the same (with 35283 samples in total, which is equal to the number of samples before filtering).Test command:
With ann_file:
Without ann_file:
Checklist
Before PR:
After PR: