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

Added filtering on accept ratio #2311

Merged
merged 3 commits into from
Jan 28, 2025
Merged

Added filtering on accept ratio #2311

merged 3 commits into from
Jan 28, 2025

Conversation

ternaus
Copy link
Collaborator

@ternaus ternaus commented Jan 27, 2025

Fixes: #2308

Summary by Sourcery

Add filtering of bounding boxes by aspect ratio.

New Features:

  • Added max_accept_ratio parameter to BboxParams to control the filtering of bounding boxes based on their aspect ratio.

Tests:

  • Added tests for the new aspect ratio filtering functionality.

Copy link
Contributor

sourcery-ai bot commented Jan 27, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new max_accept_ratio parameter to the BboxParams class and the filter_bboxes function. This parameter allows users to filter out bounding boxes based on their aspect ratio, which is calculated as the maximum of width/height and height/width. The implementation includes a new test case for the filtering logic.

Class diagram showing updated BboxParams class

classDiagram
    class BboxParams {
        +str format
        +float min_area
        +float min_visibility
        +float min_width
        +float min_height
        +bool check_each_transform
        +bool clip
        +bool filter_invalid_bboxes
        +float|None max_accept_ratio
        +__init__(format, label_fields, min_area, min_visibility, min_width, min_height, check_each_transform, clip, filter_invalid_bboxes, max_accept_ratio)
        +to_dict_private() dict
    }
    note for BboxParams "Added max_accept_ratio parameter
to filter boxes by aspect ratio"
Loading

File-Level Changes

Change Details Files
Added max_accept_ratio parameter to BboxParams class.
  • Added max_accept_ratio to the __init__ method.
  • Added max_accept_ratio to the to_dict_private method.
  • Added documentation for the new parameter.
albumentations/core/bbox_utils.py
Added max_accept_ratio parameter to filter_bboxes function.
  • Added max_accept_ratio to the function signature.
  • Implemented logic to filter bounding boxes based on the max_accept_ratio.
  • Added handling for the case when max_accept_ratio is None.
albumentations/core/bbox_utils.py
Added a new test case for filtering bounding boxes by aspect ratio.
  • Added a new test function test_filter_bboxes_aspect_ratio.
  • Added multiple test cases with different bounding box aspect ratios and max_accept_ratio values.
tests/test_bbox.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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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: 2 issues 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/core/bbox_utils.py Outdated Show resolved Hide resolved
albumentations/core/bbox_utils.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Project coverage is 89.82%. Comparing base (b1a79c2) to head (3f2a3a6).
Report is 395 commits behind head on main.

Files with missing lines Patch % Lines
albumentations/core/bbox_utils.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           main    #2311       +/-   ##
=========================================
+ Coverage      0   89.82%   +89.82%     
=========================================
  Files         0       50       +50     
  Lines         0     9024     +9024     
=========================================
+ Hits          0     8106     +8106     
- Misses        0      918      +918     
Flag Coverage Δ
ubuntu-py3.12 89.82% <85.71%> (?)

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.

@ternaus ternaus merged commit 7a65864 into main Jan 28, 2025
16 checks passed
@ternaus ternaus deleted the extand_bbox_filtering branch January 28, 2025 00:03
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.

Add max_aspect_ratio Parameter to BboxParams for Filtering Bounding Boxes Based on Aspect Ratio
1 participant