supervision/tests/detection/utils
Agis Kounelis 11a586c133
perf(detection): compute mask IoU via matmul instead of an (N, M, H, W) intermediate (#2323)
- Reimplemented dense mask IoU/IoS computation using matrix multiplication on flattened masks instead of constructing a full `(N, M, H, W)` overlap tensor
- Significantly reduced memory usage and improved performance for large mask sets while preserving identical IoU/IoS results
- Added automatic precision handling for large masks to keep intersection and area counts numerically accurate
- Improved memory-limit handling and chunking logic to reflect actual matmul memory usage
- Added validation that compared mask sets share the same spatial dimensions
- Added validation for invalid mask tensor ranks and input shapes
- Added safe handling for empty-mask inputs
- Added warnings when inputs exceed the minimum memory footprint that chunking cannot reduce
- Fixed large-mask area calculations that could produce incorrect IoU values
- Suppressed spurious runtime warnings during valid matrix-multiplication computations
- Added regression coverage for correctness, chunking, rectangular matrices, empty inputs, shape mismatches, large-mask precision, and memory-limit edge cases

---------

Co-authored-by: jirka <6035284+Borda@users.noreply.github.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
2026-06-18 10:45:56 +02:00
..
__init__.py
test_boxes.py fix(obb): NMM now computes geometric union via min-area rotated rect (#2312) 2026-06-15 16:23:31 +02:00
test_converters.py perf: vectorize `mask_to_xyxy` and `KeyPoints.as_detections` (bit-identical) (#2330) 2026-06-17 18:58:47 +02:00
test_internal.py fix(detection): preserve `class_name` string dtype on empty `Detections.from_inference` (#2270) 2026-05-27 10:39:49 +02:00
test_iou_and_nms.py perf(detection): compute mask IoU via matmul instead of an (N, M, H, W) intermediate (#2323) 2026-06-18 10:45:56 +02:00
test_masks.py Add `match` arguments to all `pytest.raises` for more precise error validation in tests (#2145) 2026-02-10 21:22:55 +09:00
test_polygons.py fix(polygons): honor target point count in `approximate_polygon` (#2332) 2026-06-17 21:11:26 +02:00
test_vlms.py