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

[Feature] Support Separated and Occluded COCO metric. #9574

Merged
merged 14 commits into from
Jan 18, 2023

Conversation

RangiLyu
Copy link
Member

@RangiLyu RangiLyu commented Jan 5, 2023

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

Support Separated and Occluded COCO metric in paper A Tri-Layer Plugin to Improve Occluded Detection.

Modification

Add OccludedSeparatedCocoDataset

Usage

Detecting occluded objects still remains a challenge for state-of-the-art object detectors.
We implemented the metric presented in paper A Tri-Layer Plugin to Improve Occluded Detection to calculate the recall of separated and occluded masks.

There are two ways to use this metric:

Offline evaluation

We provide a script to calculate the metric with a dumped prediction file.

First, use the tools/test.py script to dump the detection results:

python tools/test.py ${CONFIG} ${MODEL_PATH} --out results.pkl

Then, run the tools/analysis_tools/coco_occluded_separated_recall.py script to get the recall of separated and occluded masks:

python tools/analysis_tools/coco_occluded_separated_recall.py results.pkl --out occluded_separated_recall.json

The output should be like this:

loading annotations into memory...
Done (t=0.51s)
creating index...
index created!
processing detection results...
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 5000/5000, 109.3 task/s, elapsed: 46s, ETA:     0s
computing occluded mask recall...
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 5550/5550, 780.5 task/s, elapsed: 7s, ETA:     0s
COCO occluded mask recall: 58.79%
COCO occluded mask success num: 3263
computing separated mask recall...
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 3522/3522, 778.3 task/s, elapsed: 5s, ETA:     0s
COCO separated mask recall: 31.94%
COCO separated mask success num: 1125
+-----------+--------+-------------+
| mask type | recall | num correct |
+-----------+--------+-------------+
| occluded  | 58.79% | 3263        |
| separated | 31.94% | 1125        |
+-----------+--------+-------------+
Evaluation results have been saved to occluded_separated_recall.json.

Online evaluation

We implemented OccludedSeparatedCocoDataset which inherited from the CocoDataset.
To evaluate the recall of separated and occluded masks during training, just replace the validation dataset type with 'OccludedSeparatedCocoDataset' in your config:

data = dict(
    samples_per_gpu=2,
    workers_per_gpu=2,
    train=dict(
        type=dataset_type,
        ann_file=data_root + 'annotations/instances_train2017.json',
        img_prefix=data_root + 'train2017/',
        pipeline=train_pipeline),
    val=dict(
        type='OccludedSeparatedCocoDataset',  # modify this
        ann_file=data_root + 'annotations/instances_val2017.json',
        img_prefix=data_root + 'val2017/',
        pipeline=test_pipeline),
    test=dict(
        type='OccludedSeparatedCocoDataset',  # modify this
        ann_file=data_root + 'annotations/instances_val2017.json',
        img_prefix=data_root + 'val2017/',
        pipeline=test_pipeline))

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.

@RangiLyu RangiLyu added planned feature WIP Working in progress v-2.x labels Jan 5, 2023
@ZwwWayne ZwwWayne added this to the 2.28.0 milestone Jan 6, 2023
@RangiLyu RangiLyu removed the WIP Working in progress label Jan 9, 2023
@RangiLyu RangiLyu changed the title [WIP] Support Separated and Occluded COCO metric [Feature] Support Separated and Occluded COCO metric. Jan 9, 2023
docs/en/useful_tools.md Outdated Show resolved Hide resolved
@ZwwWayne ZwwWayne merged commit 60ddc13 into open-mmlab:dev Jan 18, 2023
thmegy pushed a commit to thmegy/mmdetection that referenced this pull request May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants