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

Boost version #2218

Merged
merged 4 commits into from
Dec 24, 2024
Merged

Boost version #2218

merged 4 commits into from
Dec 24, 2024

Conversation

ternaus
Copy link
Collaborator

@ternaus ternaus commented Dec 24, 2024

Summary by Sourcery

Update the BBoxSafeRandomCrop transform to ensure all bounding boxes are preserved in the crop and improve its documentation. Update the AtLeastOneBBoxRandomCrop transform to ensure at least one bounding box is present in the crop and improve its documentation. Bump albucore version to 0.0.23.

New Features:

  • Introduce a new cropping strategy for BBoxSafeRandomCrop that guarantees all bounding boxes are preserved.

Enhancements:

  • Improve the documentation and logic of BBoxSafeRandomCrop and AtLeastOneBBoxRandomCrop transforms.

Copy link
Contributor

sourcery-ai bot commented Dec 24, 2024

Reviewer's Guide by Sourcery

This pull request updates the albucore dependency to version 0.0.23 and improves the BBoxSafeRandomCrop and AtLeastOneBBoxRandomCrop transforms by clarifying their documentation and behavior.

Sequence diagram for BBoxSafeRandomCrop transform operation

sequenceDiagram
    participant C as Client
    participant B as BBoxSafeRandomCrop

    C->>B: transform(image, bboxes)
    activate B
    alt bboxes exist
        B->>B: Compute union of all bboxes
        B->>B: Apply erosion based on erosion_rate
        B->>B: Clip eroded union to valid coordinates
        B->>B: Sample crop coordinates
    else no bboxes
        B->>B: Compute crop height with erosion_rate
        B->>B: Set crop width (maintain aspect ratio)
        B->>B: Place crop randomly
    end
    B-->>C: return transformed image and bboxes
    deactivate B
Loading

Sequence diagram for AtLeastOneBBoxRandomCrop transform operation

sequenceDiagram
    participant C as Client
    participant A as AtLeastOneBBoxRandomCrop

    C->>A: transform(image, bboxes)
    activate A
    alt bboxes exist
        A->>A: Select random reference bbox
        A->>A: Compute eroded version of bbox
        A->>A: Calculate valid crop bounds
        A->>A: Sample crop coordinates
    else no bboxes
        A->>A: Use full image dimensions
        A->>A: Sample crop coordinates
    end
    A-->>C: return transformed image and bboxes
    deactivate A
Loading

Class diagram showing the updated crop transforms

classDiagram
    class BaseCrop {
        <<abstract>>
    }

    class BBoxSafeRandomCrop {
        +erosion_rate: float
        +p: float
        +get_params_dependent_on_data()
        +get_transform_init_args_names()
    }

    class AtLeastOneBBoxRandomCrop {
        +height: int
        +width: int
        +erosion_factor: float
        +p: float
        +get_params_dependent_on_data()
        +get_transform_init_args_names()
    }

    BaseCrop <|-- BBoxSafeRandomCrop
    BaseCrop <|-- AtLeastOneBBoxRandomCrop

    note for BBoxSafeRandomCrop "Ensures ALL bboxes are preserved in crop"
    note for AtLeastOneBBoxRandomCrop "Ensures AT LEAST ONE bbox in crop"
Loading

File-Level Changes

Change Details Files
Updated the documentation and implementation of the BBoxSafeRandomCrop transform to clarify its behavior and improve its usability.
  • Clarified the purpose and usage of the BBoxSafeRandomCrop transform, distinguishing it from AtLeastOneBboxRandomCrop.
  • Improved the explanation of the algorithm used by the transform.
  • Updated the docstrings to provide more context and examples.
  • Modified the implementation to ensure all bounding boxes are preserved in the crop.
  • Added error handling for cases where the requested crop size exceeds image dimensions.
albumentations/augmentations/crops/transforms.py
Updated the documentation and implementation of the AtLeastOneBBoxRandomCrop transform to clarify its behavior and improve its usability.
  • Clarified the purpose and usage of the AtLeastOneBBoxRandomCrop transform, distinguishing it from BBoxSafeRandomCrop.
  • Improved the explanation of the algorithm used by the transform.
  • Updated the docstrings to provide more context and examples.
  • Modified the implementation to handle cases where no bounding boxes are present more effectively.
  • Added error handling for cases where the requested crop size exceeds image dimensions.
albumentations/augmentations/crops/transforms.py
Updated the albucore dependency to version 0.0.23.
  • Changed the albucore version in setup.py from 0.0.22 to 0.0.23.
setup.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 and they look great!

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.

albumentations/augmentations/crops/transforms.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Dec 24, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 4 lines in your changes missing coverage. Please review.

Project coverage is 89.78%. Comparing base (b1a79c2) to head (aaa890d).
Report is 328 commits behind head on main.

Files with missing lines Patch % Lines
albumentations/augmentations/crops/transforms.py 83.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           main    #2218       +/-   ##
=========================================
+ Coverage      0   89.78%   +89.78%     
=========================================
  Files         0       50       +50     
  Lines         0     9100     +9100     
=========================================
+ Hits          0     8170     +8170     
- Misses        0      930      +930     

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

@ternaus ternaus merged commit e9ba83c into main Dec 24, 2024
16 checks passed
@ternaus ternaus deleted the boost_version branch December 24, 2024 20:58
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