Skip to content

refactor(metrics): update MeanAveragePrecisionResult to use float32 precision#2169

Merged
Borda merged 7 commits into
developfrom
refactor/typing
Mar 10, 2026
Merged

refactor(metrics): update MeanAveragePrecisionResult to use float32 precision#2169
Borda merged 7 commits into
developfrom
refactor/typing

Conversation

@Borda

@Borda Borda commented Mar 10, 2026

Copy link
Copy Markdown
Member
Before submitting
  • Self-reviewed the code
  • Updated documentation, follow Google-style
  • Added docs entry for autogeneration (if new functions/classes)
  • Added/updated tests
  • All tests pass locally

Description

  • 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

Type of Change

  • 🔨 Refactoring (no functional changes)
  • ⚡ Performance improvement

Motivation and Context

This change reduces memory usage and improves computation speed while maintaining acceptable precision for most computer vision tasks.

…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.
@Borda Borda requested a review from SkalskiP as a code owner March 10, 2026 15:23
Copilot AI review requested due to automatic review settings March 10, 2026 15:23
@codecov

codecov Bot commented Mar 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 74%. Comparing base (a78bf58) to head (bed4add).
⚠️ Report is 1 commits behind head on develop.

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 MeanAveragePrecisionResult arrays (mAP scores, AP per class, IoU thresholds) from float64 to float32.
  • Updates COCO evaluator thresholds/accumulation buffers and IoU computation to float32.
  • Reworks average precision aggregation to avoid masked arrays and returns float32 stats.

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.

Comment thread src/supervision/metrics/mean_average_precision.py Outdated
Comment thread src/supervision/metrics/mean_average_precision.py Outdated
Comment thread src/supervision/metrics/mean_average_precision.py Outdated
Comment thread src/supervision/metrics/mean_average_precision.py
Comment thread src/supervision/metrics/mean_average_precision.py
@Borda Borda merged commit 93f5622 into develop Mar 10, 2026
25 checks passed
@Borda Borda deleted the refactor/typing branch March 10, 2026 15:53
@Borda Borda mentioned this pull request Apr 30, 2026
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>
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.

2 participants