supervision/tests/annotators
Mahbod 2fdb970430
fix(annotators): avoid divide-by-zero in HeatMapAnnotator on empty detections (#2269)
When HeatMapAnnotator is called on a fresh annotator with empty detections
(common on the first frames of a video before the model produces any output),
self.heat_mask is all zeros, so temp / temp.max() raises
RuntimeWarning: invalid value encountered in divide and produces nan/inf
in-flight. Skip the normalisation when temp.max() == 0; the resulting
all-zero heat mask filters out via the > 0 check below, so the scene is
returned unchanged.

- Fix `kernel_size: int = 25` → `int | None = 25`; document None disables blur
- Add Note to annotate docstring: empty detections returns scene unchanged
- Add happy path test: single detection must produce visible heat output
- Add stateful tests: empty→real and real→empty sequence coverage

---------

Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
2026-05-26 22:27:07 +02:00
..
__init__.py refactor: reorganize project structure and update module imports (#2112) 2026-02-03 15:24:47 +01:00
test_core.py fix(annotators): avoid divide-by-zero in HeatMapAnnotator on empty detections (#2269) 2026-05-26 22:27:07 +02:00
test_docs.py Restructure annotator docs tabs to avoid Material’s 20-tab limit (#2257) 2026-05-22 19:54:33 +02:00
test_utils.py Added HEX↔RGBA color utilities and tests (Hacktoberfest 2025) (#1988) 2026-02-20 09:58:15 +01:00