supervision/tests/detection
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
..
tools fix(smoother): handle detections without confidence (#2333) 2026-06-17 21:16:43 +02:00
utils perf(detection): compute mask IoU via matmul instead of an (N, M, H, W) intermediate (#2323) 2026-06-18 10:45:56 +02:00
__init__.py refactor: reorganize project structure and update module imports (#2112) 2026-02-03 15:24:47 +01:00
test_compact_mask.py feat(compact_mask): add `resize()` method and benchmark stage (#2227) 2026-04-22 15:34:12 +02:00
test_compact_mask_integration.py feat: add CompactMask for memory-efficient crop-RLE mask storage (#2159) 2026-04-13 11:10:12 +02:00
test_compact_mask_iou.py feat: add CompactMask for memory-efficient crop-RLE mask storage (#2159) 2026-04-13 11:10:12 +02:00
test_core.py fix(detection): make `oriented_box_iou_batch` exact and gate non-overlapping pairs (#2317) 2026-06-15 20:54:06 +02:00
test_csv.py fix(sinks): slice list and tuple custom_data values per row (#2216) 2026-04-18 00:24:36 +02:00
test_from_adapters.py refactor: reorganize project structure and update module imports (#2112) 2026-02-03 15:24:47 +01:00
test_from_sam.py Add support for SAM3 PVS output (#2152) 2026-02-19 17:09:31 +01:00
test_inference_slicer_compact.py feat: add CompactMask for memory-efficient crop-RLE mask storage (#2159) 2026-04-13 11:10:12 +02:00
test_json.py fix(json_sink): serialize NumPy scalars in `custom_data` (#2334) 2026-06-17 22:27:03 +02:00
test_line_counter.py refactor docstrings in `scr/supervision/detection` (#2162) 2026-03-10 18:40:05 +01:00
test_polygon_zone_annotator.py refactor: reorganize project structure and update module imports (#2112) 2026-02-03 15:24:47 +01:00
test_polygonzone.py fix: prevent single object from appearing in multiple polygon zones (#1991) 2026-03-10 21:19:09 +01:00
test_vlm.py fix: return empty int ndarray instead of None for class_id on empty VLM parse (#2239) 2026-05-19 14:31:44 +02:00