refactor(metrics): update MeanAveragePrecisionResult to use float32 precision#2169
Merged
Conversation
…recision - Changed mAP_scores, ap_per_class, and iou_thresholds from float64 to float32 - Updated EPS constant to use float32 precision - Modified COCOEvaluator parameters and computations to use float32 - Added type annotations for variables in filter_segments_by_distance function - Changed precision and recall calculations to use float32 - Updated average precision computation to handle float32 values - Modified summarize_predictions to return float32 array This change reduces memory usage and improves computation speed while maintaining acceptable precision for most computer vision tasks.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #2169 +/- ##
=======================================
Coverage 74% 74%
=======================================
Files 62 62
Lines 7492 7496 +4
=======================================
+ Hits 5554 5558 +4
Misses 1938 1938 🚀 New features to boost your workflow:
|
….NDArray[np.bool_]`
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the mAP/COCO evaluation pipeline to use float32 precision for key intermediate arrays and outputs to reduce memory usage and potentially improve runtime.
Changes:
- Switches
MeanAveragePrecisionResultarrays (mAP scores, AP per class, IoU thresholds) fromfloat64tofloat32. - Updates COCO evaluator thresholds/accumulation buffers and IoU computation to
float32. - Reworks average precision aggregation to avoid masked arrays and returns
float32stats.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/supervision/metrics/mean_average_precision.py | Converts evaluator internals/results to float32, including EPS, thresholds, accumulation buffers, AP aggregation, and summary stats dtype. |
| src/supervision/detection/utils/masks.py | Adds type annotations for connected components outputs and keep_labels. |
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…sion into refactor/typing
Borda
commented
Mar 10, 2026
Borda
commented
Mar 10, 2026
Merged
Borda
added a commit
that referenced
this pull request
May 22, 2026
- Change per_class_ap50_95 field annotation float64 → float32 - Change _average_precisions_per_class return type and array init to float32 - Aligns code with 0.28.0 changelog claim (PR #2169) that metric arrays are float32 --- Co-authored-by: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before submitting
Description
Type of Change
Motivation and Context
This change reduces memory usage and improves computation speed while maintaining acceptable precision for most computer vision tasks.