Repository navigation
fix(metrics): match COCO target ties in mAR - #2758
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2758 +/- ##
=======================================
Coverage 94% 94%
=======================================
Files 83 83
Lines 13644 13644
=======================================
Hits 12839 12839
Misses 805 805 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟢 Approval recommended
The localized matching change has focused regression coverage and no unresolved blocking findings.
No open issues 🎉
What changed in this PR
🟢 Approve — This localized fix aligns mAR matching with COCO’s confidence ordering while preserving per-class detection limits and other metrics’ behavior. No actionable issues remain.
Changes:
- Match predictions by descending confidence, independently at each IoU threshold, with COCO-compatible target tie-breaking.
- Add 14 regression cases covering geometries, ordering, class isolation, thresholds, and empty inputs.
- Update the mAR docstring and changelog.
Static coverage included behavior, compatibility, tests, and documentation; tests were not rerun here. Code: 5/5 (focused implementation); testing: 5/5 (targeted regressions); documentation: 5/5 (accurate scope). Overall risk: 1/5.
| File | Description |
|---|---|
| tests/metrics/test_mean_average_recall.py | Adds confidence-order and matching-edge-case regressions. |
| src/supervision/metrics/mean_average_recall.py | Introduces the mAR-specific matcher and documents its behavior. |
| docs/changelog.md | Records the matching correction and unchanged scope. |
Review effort: Balanced
Changes: - Merge develop at a8b1ef4 into fix/mar-confidence-matching, bringing the OBB threshold precision, overflow-safe NMM area, and grayscale annotator/image updates with their regression tests. - Resolve docs changelog collision by retaining the PR roboflow#2758 target-tie entry and all fetched develop Unreleased entries. Impact: - Preserves COCO equal-IoU target tie behavior while integrating four commits made on develop after the PR base. - Keeps merged behavior and its existing tests aligned on the attached PR branch. Verification: - Affected modules: 589 passed, 3 skipped, 4 warnings. - git diff --cached --check: passed; merge analysis found one changelog collision and no other unmerged paths after resolution. Residual limits: - The PR one-line test-docstring finding remains for the separate remediation change. --- Co-authored-by: Codex <codex@openai.com>
Changes: - Shorten the equal-IoU COCO tie test docstring while preserving its ignored-region scenario. Impact: - Keeps the test purpose readable and compliant with the project one-line test docstring rule; runtime behavior is unchanged. Verification: - Focused metric test module: 46 passed. - All-file pre-commit hooks: passed. Residual limits: - Canonical full repository gate pending. --- Co-authored-by: Codex <codex@openai.com>
| # pycocotools 2.0.11 gives these AR@1/10/100 scores for both boxes and masks. | ||
| np.testing.assert_allclose(result.recall_scores, expected) | ||
| np.testing.assert_allclose(result.large_objects.recall_scores, expected) |
There was a problem hiding this comment.
Can we rather install this package as a test dependency and run live results
* fix(metrics): match mAR detections in confidence order * test(metrics): clarify COCO equal-IoU tie test --------- Co-authored-by: jirka <6035284+borda@users.noreply.github.com> Co-authored-by: Codex <codex@openai.com>
Description
After #2750 added confidence-ordered mAR matching, equal-IoU targets still chose the first eligible target instead of COCO's last-target tie rule. A higher-confidence prediction could therefore consume the only target available to a later prediction and undercount recall.
This PR now builds on the merged #2750. It reverses the eligible target indices before selecting the maximum IoU, preserving confidence order, per-class detection limits, and crowd/ignore handling. The shared matcher and other metrics are unchanged.
For targets
[0, 0, 10, 10]and[10, 0, 20, 10], with predictions[0, 0, 20, 10]and[0, 0, 10, 10]at scores0.9and0.8, current develop returns AR[0.05, 0.50, 0.50]; this fix and pycocotools return[0.05, 0.55, 0.55].Motivation and Context
Refs #2701 and follows up on #2750. Conflicts with #2750 have been resolved while retaining its crowd/ignore support and tests.
Changes Made
MeanAverageRecall#2750's overlapping-target test: official COCO gives[0.1, 0.6, 0.6]because its first prediction has equal IoU with both targets.Testing
CPU validation with Python 3.13.16 and the NumPy fallback backend:
New equal-IoU regressions on develop
4922f3a4: 9 failed; all pass with the fix.mAR tests: 46 passed. All metrics tests: 691 passed.
Full suite: 5751 passed, 123 skipped, 94% coverage. Baseline: 5733 passed, 123 skipped; every previously passing test still passes.
pre-commit run --all-files: passed, including mypy.Official pycocotools 2.0.11: 8/8 tie comparisons agree for boxes/masks, with and without crowd targets. The unmodified baseline disagrees on all eight.
Supplemental seeded comparison: 100 box scenes + 100 mask scenes, all 606 valid area results agree within
1e-7; this randomized comparison excludes crowd/ignore targets.Added/updated tests
Updated docstrings
Added an Unreleased changelog entry
Additional Notes
No new dependency or public API. Implementation and tests were developed with Codex assistance.