Skip to content

[Enchance] Add a probability parameter to Mosaic transform#7371

Merged
ZwwWayne merged 17 commits intoopen-mmlab:devfrom
RangeKing:feature
Apr 1, 2022
Merged

[Enchance] Add a probability parameter to Mosaic transform#7371
ZwwWayne merged 17 commits intoopen-mmlab:devfrom
RangeKing:feature

Conversation

@RangeKing
Copy link
Copy Markdown
Collaborator

@RangeKing RangeKing commented Mar 11, 2022

Motivation

Add a probability parameter to the mosaic transform

Modification

Add

if random.uniform(0, 1) > self.prob:
            return results

in __call__ of the mosaic transform.

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.

Not BC-breaking

Use cases (Optional)

In config file,

train_pipeline = [
    dict(type='Mosaic', img_scale=img_scale, pad_val=114, prob=0.5),
...

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.

274869388 and others added 11 commits March 1, 2022 20:55
Co-authored-by: Wenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>
* [Fix] Fix wrong img name in onnx2tensorrt.py (open-mmlab#7157)

* [Docs] fix albumentations installed way (open-mmlab#7143)

* Update finetune.md

Translate the finetune.md doc to Chinese

* Update finetune.md

* Update finetune.md

* Update finetune.md

* fix lint

* fx lint

* fix pr

Co-authored-by: Jamie <jamiechoi1995@users.noreply.github.com>
Co-authored-by: BigDong <yudongwang@tju.edu.cn>
* add cpu_num in cocopanoptic for pq computing

* cpu_num -> nproc

* move nproc to evaluate
…mlab#7258)

* allow to set channel_order when loading images

* fix lint

* fix unit test

* fix lint
…n-mmlab#7324)

* Fix softnms bug

* Add force_fp32 in corner_head and centripetal_head
* update readme and pretrained related (open-mmlab#7301)

* [Docs] Add Chinese version of onnx2tensorrt.md (open-mmlab#7219)

* Fix bug of docs

* translate onnx2tensorrt.md

* fix

* fix end-of-file-fixer

* fix some bugs

* 修复链接跳转

* 修复链接跳转

* 修复链接跳转-测试1

* 修复链接跳转-测试2

* 修复链接跳转-测试2

* 修复链接跳转-测试3

* 修复链接跳转-测试5

* Fix

Co-authored-by: jbwang1997 <jbwang1997@gmail.com>

* Update useful_tools.md (open-mmlab#7180)

* [Enhancement]: Update colab tutorials (open-mmlab#7310)

* update colab tutorials

* update

* fix

* fix wrong CUDA explaination

* resolve comments

* resolve comments

* fix typo

Co-authored-by: Cedric Luo <luochunhua1996@outlook.com>
Co-authored-by: tripleMu <92794867+q3394101@users.noreply.github.com>
Co-authored-by: jbwang1997 <jbwang1997@gmail.com>
Co-authored-by: kira <39787375+yangrisheng@users.noreply.github.com>
Co-authored-by: Wenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>
@mm-assistant mm-assistant bot added the size/XS label Mar 11, 2022
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 11, 2022

Codecov Report

Merging #7371 (873292e) into dev (86c7d8d) will decrease coverage by 0.01%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##              dev    #7371      +/-   ##
==========================================
- Coverage   63.63%   63.61%   -0.02%     
==========================================
  Files         341      341              
  Lines       27584    27588       +4     
  Branches     4660     4661       +1     
==========================================
- Hits        17552    17551       -1     
- Misses       9108     9110       +2     
- Partials      924      927       +3     
Flag Coverage Δ
unittests 63.59% <50.00%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
mmdet/datasets/pipelines/auto_augment.py 90.64% <ø> (ø)
mmdet/datasets/pipelines/transforms.py 75.17% <50.00%> (-0.09%) ⬇️
mmdet/models/roi_heads/mask_heads/maskiou_head.py 87.35% <0.00%> (-2.30%) ⬇️
mmdet/core/bbox/assigners/max_iou_assigner.py 72.36% <0.00%> (-1.32%) ⬇️
mmdet/models/losses/cross_entropy_loss.py 100.00% <0.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 86c7d8d...873292e. Read the comment docs.

@hhaAndroid hhaAndroid self-requested a review March 14, 2022 02:13
default prob is set to 0.5
@hhaAndroid
Copy link
Copy Markdown
Member

@RangeKing Hello. do you have any progress?

@hhaAndroid
Copy link
Copy Markdown
Member

@RangeKing Please fix the conflicting files

@hhaAndroid hhaAndroid self-requested a review March 23, 2022 02:54
@hhaAndroid
Copy link
Copy Markdown
Member

@RangeKing Please fix the lint

@RangeKing
Copy link
Copy Markdown
Collaborator Author

@RangeKing Please fix the lint

@hhaAndroid I saw that the lint check was successful. But some build checks were not successful. I don't know much about the build error, for example, build_cuda101 (3.7, 1.7.0+cu101). I don't know how to fix it. Any suggestions, please.

@hhaAndroid
Copy link
Copy Markdown
Member

This is because you modified the logic to cause the unit test assert error.

@ZwwWayne ZwwWayne merged commit 838996d into open-mmlab:dev Apr 1, 2022
@RangeKing RangeKing deleted the feature branch April 1, 2022 17:02
@feixiang7701
Copy link
Copy Markdown

@RangeKing Hi. RandomAffine is often used with mosaic, if set the prob=0.5, the border of RandomAffine need to change together?

border (tuple[int]): Distance from height and width sides of input image to adjust output shape. Only used in mosaic dataset.
Default: (0, 0).

@feixiang7701
Copy link
Copy Markdown

feixiang7701 commented Apr 15, 2022

In the RandomAffine
def __call__(self, results): img = results['img'] height = img.shape[0] + self.border[0] * 2 width = img.shape[1] + self.border[1] * 2 **#the height and width should be obtained from pipeline**

ZwwWayne added a commit that referenced this pull request Jul 18, 2022
* [Fix] Adjust the order of get_classes and FileClient. (#7276)

* delete -sv (#7277)

Co-authored-by: Wenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>

* [Docs] Add Chinese version of finetune (#7178)

* [Fix] Fix wrong img name in onnx2tensorrt.py (#7157)

* [Docs] fix albumentations installed way (#7143)

* Update finetune.md

Translate the finetune.md doc to Chinese

* Update finetune.md

* Update finetune.md

* Update finetune.md

* fix lint

* fx lint

* fix pr

Co-authored-by: Jamie <jamiechoi1995@users.noreply.github.com>
Co-authored-by: BigDong <yudongwang@tju.edu.cn>

* set unmap_results=True in ssd_head (#7328)

* Update YOLOX log for non square input (#7235)

* [Enhance] add cpu_num in cocopanoptic for pq computing (#7315)

* add cpu_num in cocopanoptic for pq computing

* cpu_num -> nproc

* move nproc to evaluate

* [Enhancement] Allow to set channel_order in LoadImageFromFile (#7258)

* allow to set channel_order when loading images

* fix lint

* fix unit test

* fix lint

* [Fix] Force the inputs of `get_bboxes` in yolox_head to float32. (#7324)

* Fix softnms bug

* Add force_fp32 in corner_head and centripetal_head

* [Fix] Fix typo in FPN neck (#7347)

* update readme and pretrained related (#7301)

* [Docs] Add Chinese version of onnx2tensorrt.md (#7219)

* Fix bug of docs

* translate onnx2tensorrt.md

* fix

* fix end-of-file-fixer

* fix some bugs

* 修复链接跳转

* 修复链接跳转

* 修复链接跳转-测试1

* 修复链接跳转-测试2

* 修复链接跳转-测试2

* 修复链接跳转-测试3

* 修复链接跳转-测试5

* Fix

Co-authored-by: jbwang1997 <jbwang1997@gmail.com>

* Update useful_tools.md (#7180)

* [Enhancement]: Update colab tutorials (#7310)

* update colab tutorials

* update

* fix

* fix wrong CUDA explaination

* resolve comments

* resolve comments

* fix typo

Co-authored-by: Cedric Luo <luochunhua1996@outlook.com>
Co-authored-by: tripleMu <92794867+q3394101@users.noreply.github.com>
Co-authored-by: jbwang1997 <jbwang1997@gmail.com>
Co-authored-by: kira <39787375+yangrisheng@users.noreply.github.com>
Co-authored-by: Wenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>

* Add prob parameter in Mosaic

* Update transforms.py

* Update default prob of Mosaic transform

default prob is set to 0.5

* Add unit test to prob of Mosaic

* Update default prob of Mosaic transform

Set default prob=1.

* Update auto_augment.py

fix f-string

* Update test_transform.py

Co-authored-by: Wencheng Wu <41542251+274869388@users.noreply.github.com>
Co-authored-by: Yue Zhou <592267829@qq.com>
Co-authored-by: Wenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>
Co-authored-by: MingJian.L <45811724+matrixgame2018@users.noreply.github.com>
Co-authored-by: Jamie <jamiechoi1995@users.noreply.github.com>
Co-authored-by: BigDong <yudongwang@tju.edu.cn>
Co-authored-by: Cedric Luo <26483343+chhluo@users.noreply.github.com>
Co-authored-by: Yosuke Shinya <42844407+shinya7y@users.noreply.github.com>
Co-authored-by: Cedric Luo <luochunhua1996@outlook.com>
Co-authored-by: Jingwei Zhang <zjw18@mails.tsinghua.edu.cn>
Co-authored-by: jbwang1997 <jbwang1997@gmail.com>
Co-authored-by: Xiangxu-0103 <xuxiang0103@gmail.com>
Co-authored-by: tripleMu <92794867+q3394101@users.noreply.github.com>
Co-authored-by: kira <39787375+yangrisheng@users.noreply.github.com>
ZwwWayne added a commit to ZwwWayne/mmdetection that referenced this pull request Jul 19, 2022
…b#7371)

* [Fix] Adjust the order of get_classes and FileClient. (open-mmlab#7276)

* delete -sv (open-mmlab#7277)

Co-authored-by: Wenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>

* [Docs] Add Chinese version of finetune (open-mmlab#7178)

* [Fix] Fix wrong img name in onnx2tensorrt.py (open-mmlab#7157)

* [Docs] fix albumentations installed way (open-mmlab#7143)

* Update finetune.md

Translate the finetune.md doc to Chinese

* Update finetune.md

* Update finetune.md

* Update finetune.md

* fix lint

* fx lint

* fix pr

Co-authored-by: Jamie <jamiechoi1995@users.noreply.github.com>
Co-authored-by: BigDong <yudongwang@tju.edu.cn>

* set unmap_results=True in ssd_head (open-mmlab#7328)

* Update YOLOX log for non square input (open-mmlab#7235)

* [Enhance] add cpu_num in cocopanoptic for pq computing (open-mmlab#7315)

* add cpu_num in cocopanoptic for pq computing

* cpu_num -> nproc

* move nproc to evaluate

* [Enhancement] Allow to set channel_order in LoadImageFromFile (open-mmlab#7258)

* allow to set channel_order when loading images

* fix lint

* fix unit test

* fix lint

* [Fix] Force the inputs of `get_bboxes` in yolox_head to float32. (open-mmlab#7324)

* Fix softnms bug

* Add force_fp32 in corner_head and centripetal_head

* [Fix] Fix typo in FPN neck (open-mmlab#7347)

* update readme and pretrained related (open-mmlab#7301)

* [Docs] Add Chinese version of onnx2tensorrt.md (open-mmlab#7219)

* Fix bug of docs

* translate onnx2tensorrt.md

* fix

* fix end-of-file-fixer

* fix some bugs

* 修复链接跳转

* 修复链接跳转

* 修复链接跳转-测试1

* 修复链接跳转-测试2

* 修复链接跳转-测试2

* 修复链接跳转-测试3

* 修复链接跳转-测试5

* Fix

Co-authored-by: jbwang1997 <jbwang1997@gmail.com>

* Update useful_tools.md (open-mmlab#7180)

* [Enhancement]: Update colab tutorials (open-mmlab#7310)

* update colab tutorials

* update

* fix

* fix wrong CUDA explaination

* resolve comments

* resolve comments

* fix typo

Co-authored-by: Cedric Luo <luochunhua1996@outlook.com>
Co-authored-by: tripleMu <92794867+q3394101@users.noreply.github.com>
Co-authored-by: jbwang1997 <jbwang1997@gmail.com>
Co-authored-by: kira <39787375+yangrisheng@users.noreply.github.com>
Co-authored-by: Wenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>

* Add prob parameter in Mosaic

* Update transforms.py

* Update default prob of Mosaic transform

default prob is set to 0.5

* Add unit test to prob of Mosaic

* Update default prob of Mosaic transform

Set default prob=1.

* Update auto_augment.py

fix f-string

* Update test_transform.py

Co-authored-by: Wencheng Wu <41542251+274869388@users.noreply.github.com>
Co-authored-by: Yue Zhou <592267829@qq.com>
Co-authored-by: Wenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>
Co-authored-by: MingJian.L <45811724+matrixgame2018@users.noreply.github.com>
Co-authored-by: Jamie <jamiechoi1995@users.noreply.github.com>
Co-authored-by: BigDong <yudongwang@tju.edu.cn>
Co-authored-by: Cedric Luo <26483343+chhluo@users.noreply.github.com>
Co-authored-by: Yosuke Shinya <42844407+shinya7y@users.noreply.github.com>
Co-authored-by: Cedric Luo <luochunhua1996@outlook.com>
Co-authored-by: Jingwei Zhang <zjw18@mails.tsinghua.edu.cn>
Co-authored-by: jbwang1997 <jbwang1997@gmail.com>
Co-authored-by: Xiangxu-0103 <xuxiang0103@gmail.com>
Co-authored-by: tripleMu <92794867+q3394101@users.noreply.github.com>
Co-authored-by: kira <39787375+yangrisheng@users.noreply.github.com>
SakiRinn pushed a commit to SakiRinn/mmdetection-locount that referenced this pull request Mar 17, 2023
…b#7371)

* [Fix] Adjust the order of get_classes and FileClient. (open-mmlab#7276)

* delete -sv (open-mmlab#7277)

Co-authored-by: Wenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>

* [Docs] Add Chinese version of finetune (open-mmlab#7178)

* [Fix] Fix wrong img name in onnx2tensorrt.py (open-mmlab#7157)

* [Docs] fix albumentations installed way (open-mmlab#7143)

* Update finetune.md

Translate the finetune.md doc to Chinese

* Update finetune.md

* Update finetune.md

* Update finetune.md

* fix lint

* fx lint

* fix pr

Co-authored-by: Jamie <jamiechoi1995@users.noreply.github.com>
Co-authored-by: BigDong <yudongwang@tju.edu.cn>

* set unmap_results=True in ssd_head (open-mmlab#7328)

* Update YOLOX log for non square input (open-mmlab#7235)

* [Enhance] add cpu_num in cocopanoptic for pq computing (open-mmlab#7315)

* add cpu_num in cocopanoptic for pq computing

* cpu_num -> nproc

* move nproc to evaluate

* [Enhancement] Allow to set channel_order in LoadImageFromFile (open-mmlab#7258)

* allow to set channel_order when loading images

* fix lint

* fix unit test

* fix lint

* [Fix] Force the inputs of `get_bboxes` in yolox_head to float32. (open-mmlab#7324)

* Fix softnms bug

* Add force_fp32 in corner_head and centripetal_head

* [Fix] Fix typo in FPN neck (open-mmlab#7347)

* update readme and pretrained related (open-mmlab#7301)

* [Docs] Add Chinese version of onnx2tensorrt.md (open-mmlab#7219)

* Fix bug of docs

* translate onnx2tensorrt.md

* fix

* fix end-of-file-fixer

* fix some bugs

* 修复链接跳转

* 修复链接跳转

* 修复链接跳转-测试1

* 修复链接跳转-测试2

* 修复链接跳转-测试2

* 修复链接跳转-测试3

* 修复链接跳转-测试5

* Fix

Co-authored-by: jbwang1997 <jbwang1997@gmail.com>

* Update useful_tools.md (open-mmlab#7180)

* [Enhancement]: Update colab tutorials (open-mmlab#7310)

* update colab tutorials

* update

* fix

* fix wrong CUDA explaination

* resolve comments

* resolve comments

* fix typo

Co-authored-by: Cedric Luo <luochunhua1996@outlook.com>
Co-authored-by: tripleMu <92794867+q3394101@users.noreply.github.com>
Co-authored-by: jbwang1997 <jbwang1997@gmail.com>
Co-authored-by: kira <39787375+yangrisheng@users.noreply.github.com>
Co-authored-by: Wenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>

* Add prob parameter in Mosaic

* Update transforms.py

* Update default prob of Mosaic transform

default prob is set to 0.5

* Add unit test to prob of Mosaic

* Update default prob of Mosaic transform

Set default prob=1.

* Update auto_augment.py

fix f-string

* Update test_transform.py

Co-authored-by: Wencheng Wu <41542251+274869388@users.noreply.github.com>
Co-authored-by: Yue Zhou <592267829@qq.com>
Co-authored-by: Wenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>
Co-authored-by: MingJian.L <45811724+matrixgame2018@users.noreply.github.com>
Co-authored-by: Jamie <jamiechoi1995@users.noreply.github.com>
Co-authored-by: BigDong <yudongwang@tju.edu.cn>
Co-authored-by: Cedric Luo <26483343+chhluo@users.noreply.github.com>
Co-authored-by: Yosuke Shinya <42844407+shinya7y@users.noreply.github.com>
Co-authored-by: Cedric Luo <luochunhua1996@outlook.com>
Co-authored-by: Jingwei Zhang <zjw18@mails.tsinghua.edu.cn>
Co-authored-by: jbwang1997 <jbwang1997@gmail.com>
Co-authored-by: Xiangxu-0103 <xuxiang0103@gmail.com>
Co-authored-by: tripleMu <92794867+q3394101@users.noreply.github.com>
Co-authored-by: kira <39787375+yangrisheng@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Development

Successfully merging this pull request may close these issues.