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 RMosaic #344

Merged
merged 11 commits into from
Jul 6, 2022
Merged

[Feature] Support RMosaic #344

merged 11 commits into from
Jul 6, 2022

Conversation

heiyuxiaokai
Copy link
Contributor

@heiyuxiaokai heiyuxiaokai commented Jun 10, 2022

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

Please describe the motivation of this PR and the goal you want to achieve through this PR.

Modification

1.Support RMosaic
(PS: Corresponding codes in mmdetection shows Mosaic must be used with RandomAffine. But I find Resize is also working. )

BC-breaking (Optional)

Does the modification introduce changes that break the back-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)

Use the train_pipeline as belowing:

train_pipeline = [
    dict(type='RMosaic', img_scale=(800, 800)),
    dict(type='RResize', img_scale=(800, 800)),
    dict(
        type='RRandomFlip',
        flip_ratio=[0.25, 0.25, 0.25],
        direction=['horizontal', 'vertical', 'diagonal'],
        version=angle_version),
    dict(
        type='PolyRandomRotate',
        rotate_ratio=0.5,
        angles_range=180,
        auto_bound=False,
        # rect_classes=[9, 11],
        version=angle_version),
    dict(type='Normalize', **img_norm_cfg),
    dict(type='Pad', size_divisor=32),
    dict(type='DefaultFormatBundle'),
    dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels'])
]

train_dataset = dict(
    _delete_ = True,
    type='MultiImageMixDataset',
    dataset=dict(
        type=dataset_type,
        classes=classes,
        ann_file=data_root + 'trainval/annfiles/',
        img_prefix=data_root + 'trainval/images/',
        pipeline=[
            dict(type='LoadImageFromFile'),
            dict(type='LoadAnnotations', with_bbox=True)
        ],
        version=angle_version
    ),
    pipeline=train_pipeline
)

data = dict(
    samples_per_gpu=4,
    workers_per_gpu=2,
    train=train_dataset,
    val=dict(
        classes=classes,
        ann_file=data_root + 'test/annfiles/',
        img_prefix=data_root + 'test/images/',
        pipeline=test_pipeline,
        version=angle_version),
    test=dict(
        classes=classes,
        ann_file=data_root + 'test/annfiles/',
        img_prefix=data_root + 'test/images/',
        pipeline=test_pipeline,
        version=angle_version))

Visualization

183956 43439689933
204956 98358319158
623240 0633978863

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. The documentation has been modified accordingly, like docstring or example tutorials.

@codecov
Copy link

codecov bot commented Jun 10, 2022

Codecov Report

Merging #344 (e4239d7) into dev (d6ff82d) will decrease coverage by 0.12%.
The diff coverage is 17.24%.

@@            Coverage Diff             @@
##              dev     #344      +/-   ##
==========================================
- Coverage   30.86%   30.74%   -0.13%     
==========================================
  Files         119      119              
  Lines        7934     7989      +55     
  Branches     1220     1227       +7     
==========================================
+ Hits         2449     2456       +7     
- Misses       5384     5432      +48     
  Partials      101      101              
Flag Coverage Δ
unittests 30.71% <17.24%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmrotate/datasets/pipelines/transforms.py 65.77% <14.28%> (-17.17%) ⬇️
mmrotate/datasets/pipelines/__init__.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d6ff82d...e4239d7. Read the comment docs.

@zytx121
Copy link
Collaborator

zytx121 commented Jun 10, 2022

Thank you for your PR! It's cool!
Could you please add the docstring for these functions?

@heiyuxiaokai
Copy link
Contributor Author

heiyuxiaokai commented Jun 10, 2022

Thank you for your PR! It's cool! Could you please add the docstring for these functions?

Ok, I'll update it later.

@liuyanyi
Copy link
Collaborator

Please follow https://github.com/open-mmlab/mmcv/blob/master/CONTRIBUTING.md to set pre-commit hook and fix the lint error.

@heiyuxiaokai
Copy link
Contributor Author

Please follow https://github.com/open-mmlab/mmcv/blob/master/CONTRIBUTING.md to set pre-commit hook and fix the lint error.

Thanks! I'm confused about that.

mmrotate/datasets/pipelines/transforms.py Outdated Show resolved Hide resolved
mmrotate/datasets/pipelines/transforms.py Outdated Show resolved Hide resolved
mmrotate/datasets/pipelines/transforms.py Outdated Show resolved Hide resolved
mmrotate/datasets/pipelines/transforms.py Outdated Show resolved Hide resolved
mmrotate/datasets/pipelines/transforms.py Outdated Show resolved Hide resolved
mmrotate/datasets/pipelines/transforms.py Outdated Show resolved Hide resolved
mmrotate/datasets/pipelines/transforms.py Outdated Show resolved Hide resolved
mmrotate/datasets/pipelines/transforms.py Show resolved Hide resolved
@heiyuxiaokai
Copy link
Contributor Author

heiyuxiaokai commented Jun 13, 2022

Mosaic-transform outputs twice the input images. And resize-transform convert them to original sizes, which means all gt-boxes are half of inputs'. So I choose to set the min_box_size to 10, corresponding to min_box_size(5) of randomrotate.

From the view of visualizations, there seems no problem. But I got bad performance as:
image

Maybe mosaic should be used with randomcrop, and I'll try it.

@liuyanyi
Copy link
Collaborator

Mosaic-transform outputs twice the input images. And resize-transform convert them to original sizes, which means all gt-boxes are half of inputs'. So I choose to set the min_box_size to 10, corresponding to min_box_size(5) of randomrotate.

From the view of visualizations, there seems no problem. But I got bad performance as:
image

Maybe mosaic should be used with randomcrop, and I'll try it.

For mosaic and mixup, it should revert to orginal dataset in last few epoch, such as yolox in mmdet, you can have a try. I'm working on rrandom affine, it will release in few days.

@heiyuxiaokai
Copy link
Contributor Author

Thanks for your explaining @liuyanyi . I'll have a try.

Copy link
Collaborator

@zytx121 zytx121 left a comment

Choose a reason for hiding this comment

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

LGTM

@zytx121 zytx121 mentioned this pull request Jul 1, 2022
@ZwwWayne ZwwWayne merged commit a7c4aae into open-mmlab:dev Jul 6, 2022
@zytx121 zytx121 mentioned this pull request Jul 6, 2022
@nanhui69
Copy link

Thanks for your explaining @liuyanyi . I'll have a try.

does mosaic transform should combine with mixup? if that ,could you give a sample?

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.

5 participants