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

auto_augment: img_shape broken #6259

Merged
merged 6 commits into from
Oct 18, 2021
Merged

Conversation

yellowdolphin
Copy link
Contributor

Motivation

Rotate, Shear, and Translate classes change the shape of results['img'] when applied to the image data, but do not update results['img_shape']. This happens in methods _rotate_img(), _shear_img, and _translate_img.

In consequence, methods like _rotate_bboxes, _rotate_masks get the wrong image shape from results['img_shape'].
The bboxes don't complain but pipeline raises a ValueError: "cannot reshape array of size 196249 into shape (358,358)" when applied to datasets with masks.

Modification

I added a similar line of code as in transforms.Resize._resize_img:

results['img_shape'] = results[key].shape

where key would default to img.

BC-breaking (Optional)

None (unless inconsistent shapes where somehow intended).

Use cases (Optional)

train MRCNNs with Resize, Shear, Translate from auto_augment.py

@CLAassistant
Copy link

CLAassistant commented Oct 11, 2021

CLA assistant check
All committers have signed the CLA.

@hhaAndroid
Copy link
Collaborator

@yellowdolphin Please fix the lint

@codecov
Copy link

codecov bot commented Oct 12, 2021

Codecov Report

Merging #6259 (9842176) into master (7f9facc) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6259      +/-   ##
==========================================
- Coverage   61.86%   61.83%   -0.04%     
==========================================
  Files         315      315              
  Lines       25163    25166       +3     
  Branches     4185     4185              
==========================================
- Hits        15568    15562       -6     
- Misses       8782     8796      +14     
+ Partials      813      808       -5     
Flag Coverage Δ
unittests 61.81% <100.00%> (-0.03%) ⬇️

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% <100.00%> (+0.07%) ⬆️
mmdet/models/detectors/cornernet.py 94.87% <0.00%> (-5.13%) ⬇️
mmdet/models/dense_heads/corner_head.py 67.21% <0.00%> (-2.46%) ⬇️
mmdet/models/detectors/two_stage.py 68.23% <0.00%> (ø)
mmdet/models/roi_heads/standard_roi_head.py 62.11% <0.00%> (ø)
mmdet/core/bbox/samplers/random_sampler.py 80.55% <0.00%> (+5.55%) ⬆️

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 7f9facc...9842176. Read the comment docs.

@RangiLyu
Copy link
Member

@yellowdolphin Thanks for your contribution! Please install pre-commit and run pre-commit run --all-files to fix the lint.

@yellowdolphin
Copy link
Contributor Author

@RangiLyu Done, pre-commit passes now.

@ZwwWayne ZwwWayne merged commit a32d7d4 into open-mmlab:master Oct 18, 2021
@yellowdolphin yellowdolphin deleted the auto_augment branch October 18, 2021 17:30
ZwwWayne pushed a commit to ZwwWayne/mmdetection that referenced this pull request Jul 19, 2022
* check/correct img.shape

* check/correct img.shape

* simpler fix for img_shape

* failtest Shear, Translate

* fix also _shear_img, _translate_img

* flake8
@OpenMMLab-Coodinator
Copy link

Hi @yellowdolphin !First of all, we want to express our gratitude for your significant PR in the MMDet project. Your contribution is highly appreciated, and we are grateful for your efforts in helping improve this open-source project during your personal time. We believe that many developers will benefit from your PR.

We would also like to invite you to join our Special Interest Group (SIG) private channel on Discord, where you can share your experiences, ideas, and build connections with like-minded peers. To join the SIG channel, simply message moderator— OpenMMLab on Discord or briefly share your open-source contributions in the #introductions channel and we will assist you. Look forward to seeing you there! Join us :https://discord.gg/raweFPmdzG

If you are Chinese or have WeChat,welcome to join our community on WeChat. You can add our assistant :openmmlabwx. Please add "mmsig + Github ID" as a remark when adding friends:)
Thank you again for your contribution❤

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.

6 participants