Problem
_match_predictions in perceptionmetrics/utils/detection_metrics.py computes
the IoU matrix in one fast NumPy call, but then reads it element by element
inside a Python inner loop over GT boxes. With N predictions and M GT boxes,
this results in N×M Python iterations per image, which becomes a significant
bottleneck at scale.
Fix
- Replaced the inner loop with NumPy boolean masking +
np.argmax
- Added confidence-score-based sorting of predictions before matching
(standard mAP practice, high-confidence predictions get priority)
- Kept
used_mask as a NumPy boolean array in sync with the used set
for fast masking
Testing
All 9 detection metric tests pass. Full suite: 44 passed, 2 failed
(pre-existing Open3D compatibility failures unrelated to this change).
I'd be happy to open a PR if this approach looks good to you.
Problem
_match_predictionsinperceptionmetrics/utils/detection_metrics.pycomputesthe IoU matrix in one fast NumPy call, but then reads it element by element
inside a Python inner loop over GT boxes. With N predictions and M GT boxes,
this results in N×M Python iterations per image, which becomes a significant
bottleneck at scale.
Fix
np.argmax(standard mAP practice, high-confidence predictions get priority)
used_maskas a NumPy boolean array in sync with theusedsetfor fast masking
Testing
All 9 detection metric tests pass. Full suite: 44 passed, 2 failed
(pre-existing Open3D compatibility failures unrelated to this change).
I'd be happy to open a PR if this approach looks good to you.