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

Update lut #2000

Merged
merged 4 commits into from
Oct 19, 2024
Merged

Update lut #2000

merged 4 commits into from
Oct 19, 2024

Conversation

ternaus
Copy link
Collaborator

@ternaus ternaus commented Oct 19, 2024

Fixes: #1997

Summary by Sourcery

Refactor image processing functions to use sz_lut instead of cv2.LUT for improved performance and consistency. Simplify the shift_hsv function by removing separate handling for different data types. Update the add_snow_texture function to use cv2.add for blending. Adjust the albucore dependency version in setup.py. Remove a redundant test case and update another for better precision.

Enhancements:

  • Refactor the shift_hsv function to simplify the logic and remove separate handling for uint8 and non-uint8 images.
  • Replace cv2.LUT with sz_lut for various image processing functions to improve performance and maintain consistency.
  • Modify the add_snow_texture function to use cv2.add instead of cv2.addWeighted for blending snow with the original image.
  • Update the adjust_brightness_torchvision and adjust_contrast_torchvision functions to use inplace=False for multiply and multiply_add operations.

Build:

  • Update albucore dependency version from 0.0.17 to 0.0.18 in setup.py.

Tests:

  • Remove the test_hue_saturation_value_float_uint8_equal test case from test_transforms.py.
  • Update the test_random_tone_curve test in test_functional.py to use np.testing.assert_allclose for better precision in comparisons.

Copy link
Contributor

sourcery-ai bot commented Oct 19, 2024

Reviewer's Guide by Sourcery

This pull request updates the 'lut' (Look-Up Table) functionality in the Albumentations library, focusing on optimizing image processing operations. The changes primarily affect the HSV color space transformations, solarize, posterize, and other image manipulation functions. The PR also includes updates to dependencies and some test modifications.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Refactored HSV color space transformation
  • Removed separate functions for uint8 and non-uint8 HSV shifts
  • Implemented a single, optimized HSV shift function
  • Added @uint8_io decorator to ensure consistent input/output types
  • Replaced cv2.LUT with custom sz_lut function for hue transformation
albumentations/augmentations/functional.py
Optimized image processing functions
  • Updated solarize function to use sz_lut and improve in-place operations
  • Modified posterize function to use sz_lut
  • Updated equalize functions to use sz_lut
  • Optimized gamma_transform to use sz_lut for uint8 images
albumentations/augmentations/functional.py
Updated dependencies and imports
  • Added import for sz_lut function
  • Updated albucore dependency to version 0.0.18
albumentations/augmentations/functional.py
setup.py
Modified test cases
  • Removed test_hue_saturation_value_float_uint8_equal test
  • Updated test_random_tone_curve to use np.testing.assert_allclose instead of np.array_equal
tests/test_transforms.py
tests/test_functional.py
Improved performance of image augmentation transforms
  • Updated HueSaturationValue transform to use optimized HSV shift function
  • Modified ColorJitter transform to use inplace operations where possible
albumentations/augmentations/transforms.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ternaus - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The change in the solarize function now modifies the input image directly instead of creating a copy. While this may be an optimization, it changes the function's behavior in a way that could surprise users. Consider documenting this change clearly or reverting to the previous behavior of not modifying the input.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

tests/test_functional.py Show resolved Hide resolved
albumentations/augmentations/functional.py Outdated Show resolved Hide resolved
@ternaus ternaus merged commit 7e3f128 into main Oct 19, 2024
14 checks passed
@ternaus ternaus deleted the update_lut branch October 19, 2024 01:34
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.

[Performance] Update cv2.lut with stringzilla lut
1 participant