-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix BboxProcessor filtering on max accept ratio #2313
Fix BboxProcessor filtering on max accept ratio #2313
Conversation
Reviewer's Guide by SourceryThe pull request addresses an issue where the Sequence diagram for BboxProcessor filtering with max_accept_ratiosequenceDiagram
participant Client
participant BboxProcessor
participant filter_bboxes
Client->>BboxProcessor: filter(data, shape)
Note over BboxProcessor: Now includes max_accept_ratio
BboxProcessor->>filter_bboxes: filter_bboxes(data, shape, ...)
filter_bboxes-->>BboxProcessor: filtered bounding boxes
BboxProcessor-->>Client: filtered bounding boxes
Class diagram showing BboxProcessor changesclassDiagram
class BboxProcessor {
+params: BboxParams
+filter(data: np.ndarray, shape: ShapeType) np.ndarray
}
class BboxParams {
+min_area: float
+min_visibility: float
+min_width: float
+min_height: float
+max_accept_ratio: float
}
BboxProcessor --> BboxParams: uses
note for BboxProcessor "Now correctly passes max_accept_ratio"
Flow diagram of bbox filtering processflowchart TD
A[Input Bounding Box] --> B{Check Filters}
B -->|Apply min_area| C{Check min_area}
B -->|Apply min_visibility| D{Check min_visibility}
B -->|Apply min_width| E{Check min_width}
B -->|Apply min_height| F{Check min_height}
B -->|Apply max_accept_ratio| G{Check max_accept_ratio}
C & D & E & F & G -->|Pass| H[Keep Box]
C & D & E & F & G -->|Fail| I[Filter Out Box]
H & I --> J[Return Filtered Boxes]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @CristoJV - I've reviewed your changes and they look great!
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
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@CristoJV Thank you for the catch |
Description
Issue
In the current implementation, the parameter
max_accept_ratio
is not explicitly passed in theBboxProcessor.filter
functionalbumentations/albumentations/core/bbox_utils.py
Lines 237 to 246 in 8008ca2
This omission causes the default value (
None
) formax_accept_ratio
to be used, makingBboxProcessor
effectively ignore bounding-box filtering by aspect ratio.Fix
The parameter
max_accept_ratio
is now explicitly passed in bothBboxProcessor
, ensuring the correct behavior when filtering bounding boxes based on their aspect ratio.def filter(self, data: np.ndarray, shape: ShapeType) -> np.ndarray: self.params: BboxParams return filter_bboxes( data, shape, min_area=self.params.min_area, min_visibility=self.params.min_visibility, min_width=self.params.min_width, min_height=self.params.min_height, + max_accept_ratio=self.params.max_accept_ratio )
Related
max_aspect_ratio
Parameter toBboxParams
for Filtering Bounding Boxes Based on Aspect Ratio #2308Tests Added
New test cases have been introduced to verify that
max_accept_ratio
is used in different scenarios, including:test_bbox_processor_max_accept_ratio
Verifies that
BboxProcessor.preprocess
andBboxProcessor.postprocess
respect themax_accept_ratio
.test_compose_with_max_accept_ratio
Ensures bounding boxes are filtered correctly when using Albumentations
Compose
.test_compose_max_accept_ratio_all_formats
Confirms
max_accept_ratio
filtering works forcoco
,pascal_voc
,yolo
, andalbumentations
formats.Test Details
Additional Notes
max_accept_ratio
is specified.Summary by Sourcery
Fix filtering of bounding boxes by aspect ratio using the
max_accept_ratio
parameter inBboxProcessor
.Bug Fixes:
max_accept_ratio
parameter was not being used in theBboxProcessor
, resulting in incorrect filtering of bounding boxes.Tests:
max_accept_ratio
inBboxProcessor.preprocess
,BboxProcessor.postprocess
, andCompose
with different bounding box formats.