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

Add random equalize #2143

Merged
merged 4 commits into from
Nov 17, 2024
Merged

Add random equalize #2143

merged 4 commits into from
Nov 17, 2024

Conversation

ternaus
Copy link
Collaborator

@ternaus ternaus commented Nov 16, 2024

Addresses: #2091

Summary by Sourcery

Add the RandomEqualize transformation to the library, allowing users to apply histogram equalization to images with a specified probability. Enhance the crops and transforms modules by refining the targets_as_params properties. Update tests to include the new RandomEqualize transformation.

New Features:

  • Introduce the RandomEqualize transformation, which applies histogram equalization to images with a specified probability.

Enhancements:

  • Remove the 'bboxes' target from the targets_as_params property in the crops transforms module.
  • Simplify the targets_as_params property in the transforms module by removing the 'image' target.

Tests:

  • Add test coverage for the new RandomEqualize transformation.

Copy link
Contributor

sourcery-ai bot commented Nov 16, 2024

Reviewer's Guide by Sourcery

This PR adds a new RandomEqualize transform class that provides a simplified interface for histogram equalization, designed for Kornia compatibility. The implementation inherits from the existing Equalize transform with fixed parameters. Additionally, there are minor fixes to the targets_as_params property in existing transforms.

Class diagram for the new RandomEqualize transform

classDiagram
    class Equalize {
        <<abstract>>
        +mode: str
        +by_channels: bool
        +mask: Optional
        +mask_params: tuple
        +p: float
        +get_transform_init_args_names() tuple[str, ...]
    }
    class RandomEqualize {
        +always_apply: bool | None
        +p: float
        +get_transform_init_args_names() tuple[str, ...]
    }
    Equalize <|-- RandomEqualize
    note for RandomEqualize "RandomEqualize is a specialized version of Equalize with fixed parameters for Kornia compatibility."
Loading

File-Level Changes

Change Details Files
Added new RandomEqualize transform class
  • Inherits from Equalize transform with fixed parameters (OpenCV mode and per-channel equalization)
  • Includes comprehensive documentation with usage examples and references
  • Added warning message to suggest using Equalize directly for more flexibility
  • Added to the list of available transforms
albumentations/augmentations/tk/transform.py
tests/aug_definitions.py
Modified targets_as_params property implementations
  • Removed redundant 'image' from Equalize transform's targets_as_params
  • Removed targets_as_params property from CropAndSpad transform
albumentations/augmentations/transforms.py
albumentations/augmentations/crops/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:

  • Consider splitting this PR into two separate ones: one for adding RandomEqualize, and another for the targets_as_params changes. This would make the changes easier to review and track.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 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.

albumentations/augmentations/tk/transform.py Show resolved Hide resolved
tests/aug_definitions.py Show resolved Hide resolved
Copy link

codecov bot commented Nov 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.32%. Comparing base (b1a79c2) to head (3f4df83).
Report is 275 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##           main    #2143       +/-   ##
=========================================
+ Coverage      0   90.32%   +90.32%     
=========================================
  Files         0       48       +48     
  Lines         0     8044     +8044     
=========================================
+ Hits          0     7266     +7266     
- Misses        0      778      +778     

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

@ternaus ternaus merged commit ecf5a57 into main Nov 17, 2024
16 checks passed
@ternaus ternaus deleted the add_random_equalize branch November 17, 2024 00:01
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.

1 participant