mmpretrain icon indicating copy to clipboard operation
mmpretrain copied to clipboard

[fix] fix RandomGrayscale bug, input image should be bgr format.

Open Fei-Wang opened this issue 3 years ago • 2 comments

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.

Fei-Wang avatar May 26 '22 05:05 Fei-Wang

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 26 '22 05:05 CLAassistant

@mzr1996

Fei-Wang avatar Aug 26 '22 07:08 Fei-Wang

Can you describe under what circumstances the bug will occur?

Ezra-Yu avatar Sep 27 '22 03:09 Ezra-Yu

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

Fei-Wang avatar Sep 27 '22 05:09 Fei-Wang

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.

mzr1996 avatar Sep 28 '22 00:09 mzr1996

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.

Fei-Wang avatar Sep 28 '22 06:09 Fei-Wang