8000 [Feature] Support TTA by zytx121 · Pull Request #9452 · open-mmlab/mmdetection · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Feature] Support TTA #9452

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

Merged
merged 22 commits into from
Feb 14, 2023
Merged

[Feature] Support TTA #9452

merged 22 commits into from
Feb 14, 2023

Conversation

zytx121
Copy link
Collaborator
@zytx121 zytx121 commented Dec 6, 2022

open-mmlab/mmengine#611 is required.

Motivation

To support Test-Time-Aug (TTA).

Modification

  • Add DetTTAModel inherited from the BaseTTAModel in MMEngine.
  • Add --tta option in tools/test.py to enable TTA during the test.

Use cases

To use the default TTA (average the classification scores of images w/ and w/o flip)

 python tools/test.py configs/retinanet/retinanet_r50_fpn_1x_coco.py checkpoints/resnet50_coco.pth --tta

To use your own custom TTA method

  1. Add tta_model and tta_pipeline in your config file:
tta_model = dict(
   type='DetTTAModel',
   tta_cfg=dict(nms=dict(type='nms', iou_threshold=0.5), max_per_img=100))
tta_pipeline = [
       dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')),
       dict(type='TestTimeAug',
            transforms=[
                [dict(type='Resize', scale=(1333, 800), keep_ratio=True),
                 dict(type='Resize', scale=(1333, 600), keep_ratio=True)],
                [dict(type='RandomFlip', prob=1.),
                 dict(type='RandomFlip', prob=0.)],
                [dict(type='LoadAnnotations', with_bbox=True)],
                [dict(type='PackDetInputs',
                      meta_keys=('img_id', 'img_path', 'ori_shape',
                                 'img_shape', 'scale_factor', 'flip',
                                 'flip_direction'))]])
   ]
  1. test with TTA
python tools/test.py configs/retinanet/retinanet_r50_fpn_1x_coco.py checkpoints.pth --tta

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.

@zytx121 zytx121 added the WIP Working in progress label Dec 6, 2022
@ZwwWayne ZwwWayne requested a review from hhaAndroid December 12, 2022 06:40
@ZwwWayne ZwwWayne added this to the 3.0.0rc6 milestone Dec 19, 2022
@zytx121 zytx121 removed the WIP Working in progress label Dec 30, 2022
Copy link
Member
@RangiLyu RangiLyu left a comment

Choose a reason for hiding this comment

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

Remember to update the document of TTA after the usage is confirmed.

@hhaAndroid
Copy link
Collaborator

@zytx121 Please synchronize the latest code to ensure that ci can pass

@ZwwWayne ZwwWayne requested a review from hhaAndroid February 2, 2023 03:11
@zytx121
Copy link
Collaborator Author
zytx121 commented Feb 5, 2023

@zytx121 Please synchronize the latest code to ensure that ci can pass

Done.

@zytx121 zytx121 requested a review from RangiLyu February 8, 2023 11:15
RangiLyu
RangiLyu previously approved these changes Feb 8, 2023
Copy link
Member
@RangiLyu RangiLyu left a comment

Choose a reason for hiding this comment

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

LGTM. It would be better if you can add a warning in test.py if there is no tta_cfg in the config.

@RangiLyu
Copy link
Member
RangiLyu commented Feb 8, 2023

Add the use case to docs/en/user_guides/test.md

@zytx121
Copy link
Collaborator Author
zytx121 commented Feb 8, 2023

Add the use case to docs/en/user_guides/test.md

LGTM. It would be better if you can add a warning in test.py if there is no tta_cfg in the config.

Done.

@ZwwWayne ZwwWayne requested a review from RangiLyu February 8, 2023 13:58
RangiLyu
RangiLyu previously approved these changes Feb 9, 2023
hhaAndroid
hhaAndroid previously approved these changes Feb 9, 2023
Co-authored-by: Wenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>
@zytx121 zytx121 requested a review from ZwwWayne February 12, 2023 06:13
@ZwwWayne ZwwWayne merged commit 99e02c7 into open-mmlab:dev-3.x Feb 14, 2023
yumion pushed a commit to yumion/mmdetection that referenced this pull request Jan 31, 2024
…mlab#9452)

Co-authored-by: RangiLyu <lyuchqi@gmail.com>
Co-authored-by: Wenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>
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.

4 participants
0