Skip to content

Fix BGR->RGB Bug in albumentations #8641#8695

Merged
glenn-jocher merged 7 commits intoultralytics:masterfrom
UnglvKitDe:fix/albumentations_rgb
Jul 26, 2022
Merged

Fix BGR->RGB Bug in albumentations #8641#8695
glenn-jocher merged 7 commits intoultralytics:masterfrom
UnglvKitDe:fix/albumentations_rgb

Conversation

@UnglvKitDe
Copy link
Copy Markdown
Contributor

@UnglvKitDe UnglvKitDe commented Jul 23, 2022

@glenn-jocher First idea. Easy, but maybe not the fastest one...

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Improved image augmentation compatibility for BGR image inputs.

📊 Key Changes

  • Augmentation now converts images from BGR to RGB before applying transformations.
  • After transformations, images are converted back from RGB to BGR.

🎯 Purpose & Impact

  • Purpose: Ensures image augmentations are applied correctly when the input images are in BGR format, which is common in OpenCV.
  • Impact: Users can now expect consistent augmentation results even if their images start in BGR format, leading to potentially more accurate models when training with images processed by OpenCV. This change also streamlines preprocessing steps for users working with BGR images.

@UnglvKitDe UnglvKitDe force-pushed the fix/albumentations_rgb branch from 7910199 to 44004d1 Compare July 23, 2022 23:33
@glenn-jocher
Copy link
Copy Markdown
Member

@UnglvKitDe yes this is probably the simplest fix but not a very good one. I think we need to convert the LoadImagesAndLabels dataloader to be fully RGB. I'll merge this now as a temp fix though so I don't forget.

@glenn-jocher glenn-jocher linked an issue Jul 26, 2022 that may be closed by this pull request
2 tasks
@glenn-jocher glenn-jocher merged commit 2e1291f into ultralytics:master Jul 26, 2022
@UnglvKitDe
Copy link
Copy Markdown
Contributor Author

@glenn-jocher I looked at it. Think it might be worth adding it right after the image loading and rebuilding the other methods. Because we don't really have any opencv operations in the data loader anymore except in augmentations. Good point!

@glenn-jocher
Copy link
Copy Markdown
Member

Caused bug in #8724

glenn-jocher added a commit that referenced this pull request Jul 26, 2022
glenn-jocher added a commit that referenced this pull request Jul 26, 2022
glenn-jocher added a commit that referenced this pull request Jul 26, 2022
Revert "Fix BGR->RGB Bug in albumentations #8641 (#8695)"

This reverts commit 2e1291f.
@glenn-jocher
Copy link
Copy Markdown
Member

@glenn-jocher I looked at it. Think it might be worth adding it right after the image loading and rebuilding the other methods. Because we don't really have any opencv operations in the data loader anymore except in augmentations. Good point!

Second fix attempt PR #8747, can you please review?

ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this pull request Sep 8, 2022
* Fix BGR->RGB Bug in albumentations ultralytics#8641

* Change transform methode from cv2 to numpy

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Simplify

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update augmentations.py

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this pull request Sep 8, 2022
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.

Albumentations-Pipeline is applied to BGR not to RGB

2 participants