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

ultralytics 8.3.83 Revert saturation and value augmentation to relative shift #19515

Merged
merged 4 commits into from
Mar 4, 2025

Conversation

Y-T-G
Copy link
Collaborator

@Y-T-G Y-T-G commented Mar 4, 2025

Reverting changes from #19311 for saturation and value because the old approach with relative shift produces more natural looking images than using constant shifts.

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

This PR updates the version to 8.3.83 and refines the image augmentation logic for color transformations, fixing a bug and improving accuracy. 🎨✨

📊 Key Changes

  • Updated __version__ to 8.3.83. 🆕
  • Refined the logic for random hue, saturation, and value (HSV) adjustments in image augmentation:
    • Simplified randomization calculations for better clarity and accuracy.
    • Fixed a bug affecting hue adjustments, aligning the code with intended behavior.
    • Ensured transformations adhere to constraints like retaining pure white (lut_sat[0] = 0).

🎯 Purpose & Impact

  • Bug Fixes: Corrected hue adjustment logic, ensuring accurate color transformations. 🎯
  • Improved Augmentations: Delivers more reliable and visually consistent image preprocessing, aiding model training quality. 🔍
  • Version Bump: Signals a minor but important update to users. 🔔

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Signed-off-by: Mohammed Yasin <32206511+Y-T-G@users.noreply.github.com>
@UltralyticsAssistant UltralyticsAssistant added detect Object Detection issues, PR's enhancement New feature or request labels Mar 4, 2025
@UltralyticsAssistant
Copy link
Member

👋 Hello @Y-T-G, thank you for submitting an ultralytics/ultralytics 🚀 PR! To ensure a seamless integration of your work, please review the following checklist:

  • Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
  • Synchronize with Source: Confirm your PR is synchronized with the ultralytics/ultralytics main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
  • Update Documentation: Update the relevant documentation for any new or modified features.
  • Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
  • Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
  • Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

For more guidance, please refer to our Contributing Guide. Don’t hesitate to leave a comment if you have any questions.

The proposed change to revert the augmentation logic to relative shifts sounds promising for more natural image transformations! 🎨 If you have test results or usage examples that highlight the improvements, please consider including them in your description or PR summary. This will help us better understand the impact!

Thank you for contributing to Ultralytics! 🌟 An Ultralytics engineer will review your PR shortly. 😊

Copy link

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.23%. Comparing base (9e3ab2b) to head (875a4c0).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #19515      +/-   ##
==========================================
+ Coverage   73.21%   73.23%   +0.02%     
==========================================
  Files         129      129              
  Lines       17583    17583              
==========================================
+ Hits        12873    12877       +4     
+ Misses       4710     4706       -4     
Flag Coverage Δ
Benchmarks 34.11% <16.66%> (+0.03%) ⬆️
GPU 37.87% <16.66%> (ø)
Tests 67.05% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Laughing-q
Copy link
Member

@glenn-jocher After some more tests on more images, we think it's better to revert the "fix" we made for saturation and value in hsv, since original implementation looks more natural:
image
img_v3_02k2_bb089722-827f-41d1-a0af-d2bd493fa69g
Noted our main branch implementation of saturation is the same as albumentation, however I also tested the saturation augmentation from torchvision.transforms and it behaves the same as this PR, and since the augmented image from this PR looks more natural I think we can go with this PR.

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
@glenn-jocher glenn-jocher changed the title Revert saturation and value augmentation to relative shift ultralytics 8.3.83 Revert saturation and value augmentation to relative shift Mar 4, 2025
@glenn-jocher glenn-jocher merged commit fde880d into main Mar 4, 2025
14 checks passed
@glenn-jocher glenn-jocher deleted the sat-val-aug branch March 4, 2025 17:38
@glenn-jocher
Copy link
Member

Got it, thanks guys! PR merged.

@UltralyticsAssistant
Copy link
Member

🎉 Awesome work, team! This merge is a testament to the brilliance of collaboration—thank you, @Y-T-G, @Laughing-q, and @glenn-jocher, for your efforts! 🙌 As Albert Einstein once said, "Strive not to be a success, but rather to be of value." Your contributions not only fixed a critical bug but also elevated the quality of our image augmentations, directly enhancing user experiences and model performance. 🚀 Version 8.3.83 shines brighter because of your dedication—thank you! 💡✨

@chinakook
Copy link

I think we can introduce two additional variables, sat_beta and val_beta, to accommodate both scenarios.

lut_sat = np.clip(x * (r[1] + 1) + sat_beta, 0, 255).astype(dtype)
lut_val = np.clip(x * (r[2] + 1) + val_beta, 0, 255).astype(dtype)

@glenn-jocher
Copy link
Member

@chinakook thank you for the suggestion! After careful evaluation in our recent PR (#19311), we've determined that the current relative shift implementation for saturation/value adjustments produces the most natural augmentations while maintaining simplicity. For those interested in the technical details, the RandomHSV augmentation documentation explains our approach clearly.

We appreciate community contributions and encourage you to explore different augmentation strategies in your projects while following our AGPL-3.0 license terms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
detect Object Detection issues, PR's enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants