mmpretrain
mmpretrain copied to clipboard
[fix] fix RandomGrayscale bug, input image should be bgr format.
Motivation
Fix RandomGrayscale bug.
Modification
change rgb2gray to bgr2gray.
Checklist
Before PR:
- [x] Pre-commit or other linting tools are used to fix the potential lint issues.
- [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests.
- [x] The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
- [x] The documentation has been modified accordingly, like docstring or example tutorials.
After PR:
- [x] If the modification has potential influence on downstream or other related projects, this PR should be tested with those projects, like MMDet or MMSeg.
- [x] CLA has been signed and all committers have signed the CLA in this PR.
@mzr1996
Can you describe under what circumstances the bug will occur?
Because in general data aug is earlier than norm, and data aug is in bgr format. If you follow the current practice, you need to bgr2rgb before grayscale, and then rgb2bgr after it is done (although grayscale does not need it), because norm generally does bgr2rgb by default. https://github.com/open-mmlab/mmclassification/blob/c94e9b36699094ca8cfd975442474ca4ac47f083/configs/base/datasets/imagenet_bs64_pil_resize_autoaug.py#L17-L18
Yes, I know it's before normalization. But for some datasets, like CIFAR, the images are not loaded from files, and these images are in RGB format.
Yes, I know it's before normalization. But for some datasets, like CIFAR, the images are not loaded from files, and these images are in RGB format.
Thanks for your reply, you are right. I just have a question, because the current situation is that the channel order is different when apply aug, Why not image processed same when it is loaded?
Now you are free to close this pr.