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

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

Merged
merged 7 commits into from
Jul 26, 2022

Conversation

UnglvKitDe
Copy link
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.

@glenn-jocher
Copy link
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
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
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
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