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 elastic #2047

Merged
merged 3 commits into from
Nov 1, 2024
Merged

Update elastic #2047

merged 3 commits into from
Nov 1, 2024

Conversation

ternaus
Copy link
Collaborator

@ternaus ternaus commented Nov 1, 2024

Fixes: #2046

Summary by Sourcery

Add support for configurable noise distribution in the ElasticTransform class, allowing users to select between Gaussian and uniform distributions for displacement fields. Refactor related functions for improved clarity and update the pre-commit configuration to the latest Ruff version.

New Features:

  • Introduce a new parameter 'noise_distribution' to the ElasticTransform class, allowing users to choose between 'gaussian' and 'uniform' noise distributions for generating displacement fields.

Enhancements:

  • Refactor the generate_displacement_fields function to support different noise distributions and improve code readability.

Build:

  • Update the pre-commit configuration to use Ruff version v0.7.2.

Copy link
Contributor

sourcery-ai bot commented Nov 1, 2024

Reviewer's Guide by Sourcery

This PR enhances the elastic transform functionality by adding support for different noise distributions (Gaussian and uniform) in displacement field generation. The implementation refactors the displacement field generation code into a separate function and adds a new parameter to control the noise distribution type.

Updated class diagram for ElasticTransform

classDiagram
    class ElasticTransform {
        +float alpha
        +float sigma
        +bool approximate
        +bool same_dxdy
        +Literal["gaussian", "uniform"] noise_distribution
        +int mask_interpolation
        +float p
        +get_params_dependent_on_data(params: dict[str, Any], data: dict[str, Any]) dict[str, Any]
        +get_transform_init_args_names() tuple[str, ...]
    }
    note for ElasticTransform "Added noise_distribution attribute and updated methods to use it."
Loading

Updated class diagram for generate_displacement_fields function

classDiagram
    class generate_displacement_fields {
        +np.ndarray image_shape
        +float alpha
        +float sigma
        +bool same_dxdy
        +tuple[int, int] kernel_size
        +np.random.Generator random_generator
        +Literal["gaussian", "uniform"] noise_distribution
        +generate_noise_field() np.ndarray
    }
    note for generate_displacement_fields "Refactored to include noise_distribution and generate_noise_field function."
Loading

File-Level Changes

Change Details Files
Added support for different noise distributions in elastic transform
  • Added new 'noise_distribution' parameter to control the type of noise (gaussian or uniform)
  • Refactored displacement field generation into a separate helper function
  • Added documentation for the new noise_distribution parameter
  • Updated function signatures and initialization arguments to include the new parameter
albumentations/augmentations/geometric/functional.py
albumentations/augmentations/geometric/transforms.py
Updated development tooling
  • Bumped ruff-pre-commit from v0.7.1 to v0.7.2
.pre-commit-config.yaml

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 expanding the PR description to explain the motivation for adding the new noise distribution option and its expected benefits. This helps reviewers and future maintainers understand the context better.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 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.

Copy link

codecov bot commented Nov 1, 2024

Codecov Report

Attention: Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.

Project coverage is 90.31%. Comparing base (b1a79c2) to head (55c7668).
Report is 246 commits behind head on main.

Files with missing lines Patch % Lines
...bumentations/augmentations/geometric/functional.py 70.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           main    #2047       +/-   ##
=========================================
+ Coverage      0   90.31%   +90.31%     
=========================================
  Files         0       46       +46     
  Lines         0     7597     +7597     
=========================================
+ Hits          0     6861     +6861     
- Misses        0      736      +736     

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

@ternaus ternaus merged commit ffb3263 into main Nov 1, 2024
16 checks passed
@ternaus ternaus deleted the update_elastic branch November 1, 2024 21:11
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.4.21 breaks ElasticTransform (in generate_displacement_fields)
1 participant