Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
---
description: Full version history of the supervision Python library — release notes, breaking changes, new features, and deprecations for every version.
date_modified: 2026-08-04
date_modified: 2026-08-11
---

# Changelog

### Unreleased <small>upcoming</small>

### Fixed

- `sv.box_iou` now calculates overlap in `float64`, preventing `int32` area overflow for large boxes. Its scalar result now matches `sv.box_iou_batch` for the same input.

### 0.30.0 <small>Aug 4, 2026</small>

!!! failure "Python 3.9 Support Terminated"
Expand Down
12 changes: 8 additions & 4 deletions src/supervision/detection/utils/iou_and_nms.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ def _validate_iou_threshold(iou_threshold: float) -> None:


def box_iou(
box_true: list[float] | npt.NDArray[np.floating],
box_detection: list[float] | npt.NDArray[np.floating],
box_true: list[float] | npt.NDArray[np.number],
box_detection: list[float] | npt.NDArray[np.number],
overlap_metric: OverlapMetric | str = OverlapMetric.IOU,
) -> float:
"""
Expand Down Expand Up @@ -137,8 +137,12 @@ def box_iou(
```
"""
overlap_metric = OverlapMetric.from_value(overlap_metric)
x_min_true, y_min_true, x_max_true, y_max_true = np.array(box_true)
x_min_det, y_min_det, x_max_det, y_max_det = np.array(box_detection)
x_min_true, y_min_true, x_max_true, y_max_true = np.asarray(
Comment thread
Nikhi00718 marked this conversation as resolved.
Outdated
box_true, dtype=np.float64
)
x_min_det, y_min_det, x_max_det, y_max_det = np.asarray(
box_detection, dtype=np.float64
)

x_min_inter = max(x_min_true, x_min_det)
y_min_inter = max(y_min_true, y_min_det)
Expand Down
23 changes: 23 additions & 0 deletions tests/detection/utils/test_iou_and_nms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,29 @@ def test_box_iou_batch_int32_input_does_not_overflow() -> None:
assert result[0, 0] == pytest.approx(1.0 / 3.0, rel=1e-6)


@pytest.mark.parametrize(
("overlap_metric", "expected"),
[
pytest.param(OverlapMetric.IOU, 1.0 / 3.0, id="iou"),
pytest.param(OverlapMetric.IOS, 0.5, id="ios"),
],
)
def test_box_iou_int32_input_does_not_overflow(
overlap_metric: OverlapMetric, expected: float
) -> None:
"""Large int32 boxes preserve their analytic overlap scores."""
side, shift = 60000, 30000
box_a, box_b = _boundary_box_pair(0, side=side, shift=shift, dtype=np.int32)

result = box_iou(
box_true=box_a[0],
box_detection=box_b[0],
overlap_metric=overlap_metric,
)

assert result == pytest.approx(expected, rel=1e-6)


@pytest.mark.parametrize(
"scale",
[
Expand Down
Loading