Repository navigation
fix(metrics): count COCO boundary areas in both mAR size buckets - #2848
Conversation
MeanAverageRecall filtered targets with ObjectSizeCategory's half-open bins, so an object of area exactly 32² or 96² belonged to only one bucket. pycocotools and MeanAveragePrecision use inclusive ranges and count those boundary areas in both neighbouring buckets. Filter mAR size buckets with the same inclusive COCO ranges as mAP. Leave ObjectSizeCategory's half-open bins unchanged for general use.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🟡 Changes recommended
Float16 area multiplication can overflow before conversion to float64, causing valid large boxes to be incorrectly excluded from the large-object bucket.
1 open issue
What changed in this PR
This PR addresses #2846 by aligning MeanAverageRecall size buckets with COCO’s inclusive boundaries, while preserving ObjectSizeCategory’s half-open bins for general filtering.
Changes:
- Includes areas exactly 32² and 96² in both neighboring mAR buckets.
- Adds area extraction for boxes, masks, oriented boxes, and explicit area metadata.
- Adds regression tests for perfect predictions at both boundaries.
| File | Description |
|---|---|
tests/metrics/test_mean_average_recall.py |
Tests boundary inclusion and unchanged empty-bucket results. |
src/supervision/metrics/utils/object_size.py |
Adds per-detection area extraction helpers. |
src/supervision/metrics/mean_average_recall.py |
Replaces half-open category filtering with inclusive COCO ranges. |
Review effort: Balanced
|
CI was red because |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #2848 +/- ##
=======================================
- Coverage 94% 94% -0%
=======================================
Files 83 83
Lines 13975 14059 +84
=======================================
+ Hits 13206 13282 +76
- Misses 769 777 +8 🚀 New features to boost your workflow:
|
A float16 box such as [0, 0, 256, 256] overflowed to an infinite area because the subtraction and multiplication ran in float16, so the finite COCO upper bound dropped it from the large bucket. Also fix the pre-commit failures: wrap the long docstring line, use 'x' instead of the multiplication sign, and type the test helper's return as MeanAverageRecallResult.
Changes: - Parametrize mAR size bucket coverage for 32×32, 96×96, and both boundary boxes together. - Move the detection area utility import to module scope. Impact: - Reports each boundary scenario independently and checks their combined result. Verification: - Mean average recall test file: 53 passed in an existing compatible environment. - Repository-wide pre-commit checks: passed. - git diff --check: passed. Residual limits: - Full coverage suite stopped during collection because the available environment lacks scikit-learn. --- Co-authored-by: Codex <[email protected]>
MeanAverageRecall filtered targets with ObjectSizeCategory's half-open bins, so an object of area exactly 32² or 96² belonged to only one bucket. pycocotools and MeanAveragePrecision use inclusive ranges and count those boundary areas in both neighbouring buckets. Filter mAR size buckets with the same inclusive COCO ranges as mAP. Leave ObjectSizeCategory's half-open bins unchanged for general use. * test(metrics): use a 33x33 target for the empty small-bucket mAR test * fix(metrics): promote float box coordinates before computing areas * test(metrics): parametrize recall size boundary cases --------- Co-authored-by: kevin9327 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jirka Borovec <[email protected]> Co-authored-by: Codex <[email protected]>

Summary
Fixes #2846.
MeanAverageRecallfiltered size buckets withObjectSizeCategory's half-open bins (area < 32²,32² <= area < 96²,area >= 96²). An object whose area is exactly32²or96²therefore landed in only one bucket.pycocotools and this repo's
MeanAveragePrecisionuse inclusive COCO ranges ([0, 32²],[32², 96²],[96², 1e5²]), so the same object is counted in both neighbouring buckets. On identical data, mAR and mAP disagreed about which bucket an object belonged to.Filter mAR size buckets with those inclusive ranges.
ObjectSizeCategorystays half-open for general filtering.Testing
TestMeanAverageRecallCocoSizeBuckets.test_boundary_area_belongs_to_both_coco_size_buckets32×32prediction scoresmAR@100 = 1in both small and medium; a perfect96×96scores1in both medium and largeAI-assisted (Grok)