Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
08226e9
Merge pull request #1893 from roboflow/main
SkalskiP Jul 16, 2025
71d6670
fix(metrics): update area calculation in MeanAveragePrecision to use …
balthazur Jul 16, 2025
3f926c6
fix: cleanup comments
balthazur Jul 16, 2025
4009f9d
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] Jul 16, 2025
a444b3b
fix: cleanup comment
balthazur Jul 16, 2025
bf88636
Merge branch 'fix/mAP-area' of https://github.com/roboflow/supervisio…
balthazur Jul 16, 2025
40d4c6f
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] Jul 16, 2025
0ddbcb2
fix: start id with 1 because 0 means no match
balthazur Jul 17, 2025
2c67cee
fix: tests and adjust comment
balthazur Jul 17, 2025
2907c40
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] Jul 17, 2025
2e72e70
basic fix
balthazur Jul 18, 2025
001a425
fix: improve code, more fixes and add tests
balthazur Jul 18, 2025
afdbb0a
fix: keep it DRY
balthazur Jul 18, 2025
a139fb0
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] Jul 18, 2025
118e3a4
fix: line length
balthazur Jul 18, 2025
1c8ec0a
Merge pull request #1898 from roboflow/fix/negative-mAP-values
soumik12345 Jul 18, 2025
d777438
Merge branch 'develop' into fix/mAP-area
balthazur Jul 18, 2025
6e30011
improve tests
balthazur Jul 18, 2025
704652a
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] Jul 18, 2025
f044398
fix: 🐞 update inference_slicer.py for improved detection handling
onuralpszr Jul 20, 2025
db51a9f
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] Jul 20, 2025
1adb755
bump version from `0.26.0` to `0.26.1`; improve docstrings; unify nam…
SkalskiP Jul 20, 2025
c54d16c
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] Jul 20, 2025
baa0402
Merge pull request #1901 from roboflow/fix/inference-overlap-metric-fix
SkalskiP Jul 20, 2025
e8cb962
bump version from `0.26.1` to `0.26.1rc0`
SkalskiP Jul 21, 2025
d251677
Merge pull request #1894 from roboflow/fix/mAP-area
SkalskiP Jul 22, 2025
d067f32
fix: border thickness parameter usage for PercentageBarAnnotator
soumik12345 Jul 22, 2025
0c8a9d3
Merge pull request #1906 from roboflow/fix/border_thickness
SkalskiP Jul 22, 2025
ad4f446
update: changelog for 0.26.1
soumik12345 Jul 22, 2025
580fcdd
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] Jul 22, 2025
cb6018e
final changes before supervision-0.26.1
SkalskiP Jul 23, 2025
317ac08
Merge pull request #1907 from roboflow/changelog/0.26.1
SkalskiP Jul 23, 2025
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
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# These owners will be the default owners for everything in
# the repo. They will be requested for review when someone
# opens a pull request.
* @SkalskiP @onuralpszr
* @SkalskiP @soumik12345
26 changes: 19 additions & 7 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

### 0.26.1 <small>Jul 22, 2025</small>

- Fixed [1894](https://github.com/roboflow/supervision/pull/1894): Error in [`sv.MeanAveragePrecision`](https://supervision.roboflow.com/0.26.1/metrics/mean_average_precision/#supervision.metrics.mean_average_precision.MeanAveragePrecision) where the area used for size-specific evaluation (small / medium / large) was always zero unless explicitly provided in `sv.Detections.data`.

- Fixed [1895](https://github.com/roboflow/supervision/pull/1895): `ID=0` bug in [`sv.MeanAveragePrecision`](https://supervision.roboflow.com/0.26.1/metrics/mean_average_precision/#supervision.metrics.mean_average_precision.MeanAveragePrecision) where objects were getting `0.0` mAP despite perfect IoU matches due to a bug in annotation ID assignment.

- Fixed [1898](https://github.com/roboflow/supervision/pull/1898): Issue where [`sv.MeanAveragePrecision`](https://supervision.roboflow.com/0.26.1/metrics/mean_average_precision/#supervision.metrics.mean_average_precision.MeanAveragePrecision) could return negative values when certain object size categories have no data.

- Fixed [1901](https://github.com/roboflow/supervision/pull/1901): `match_metric` support for [`sv.Detections.with_nms`](https://supervision.roboflow.com/0.26.1/metrics/mean_average_precision/#supervision.detection.core.Detections.with_nms).

- Fixed [1906](https://github.com/roboflow/supervision/pull/1906): `border_thickness` parameter usage for [`sv.PercentageBarAnnotator`](https://supervision.roboflow.com/0.26.1/metrics/mean_average_precision/#supervision.annotators.core.PercentageBarAnnotator).

### 0.26.0 <small>Jul 16, 2025</small>

!!! failure "Removed"
Expand Down Expand Up @@ -153,7 +165,7 @@

- Changed [#1786](https://github.com/roboflow/supervision/pull/1786): Significantly improved the speed of HSV color mapping in [`sv.HeatMapAnnotator`](https://supervision.roboflow.com/0.26.0/detection/annotators/#supervision.annotators.core.HeatMapAnnotator), achieving approximately 28x faster performance on 1920x1080 frames.

- Fix [#1834](https://github.com/roboflow/supervision/pull/1834): Supervision’s [`sv.MeanAveragePrecision`](https://supervision.roboflow.com/0.26.0/metrics/mean_average_precision/#supervision.metrics.mean_average_precision.MeanAveragePrecision) is now fully aligned with [pycocotools](https://github.com/ppwwyyxx/cocoapi), the official COCO evaluation tool, ensuring accurate and standardized metrics. This update enabled us to launch a new version of the [Computer Vision Model Leaderboard](https://leaderboard.roboflow.com/).
- Fixed [#1834](https://github.com/roboflow/supervision/pull/1834): Supervision’s [`sv.MeanAveragePrecision`](https://supervision.roboflow.com/0.26.0/metrics/mean_average_precision/#supervision.metrics.mean_average_precision.MeanAveragePrecision) is now fully aligned with [pycocotools](https://github.com/ppwwyyxx/cocoapi), the official COCO evaluation tool, ensuring accurate and standardized metrics. This update enabled us to launch a new version of the [Computer Vision Model Leaderboard](https://leaderboard.roboflow.com/).

```python
import supervision as sv
Expand All @@ -173,7 +185,7 @@
# Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.629
```

- Fix [#1767](https://github.com/roboflow/supervision/pull/1767): Fixed losing `sv.Detections.data` when detections filtering.
- Fixed [#1767](https://github.com/roboflow/supervision/pull/1767): Fixed losing `sv.Detections.data` when detections filtering.

### 0.25.0 <small>Nov 12, 2024</small>

Expand Down Expand Up @@ -557,9 +569,9 @@ detections = sv.Detections.from_sam(sam_result=sam_result)

- Changed [#1434](https://github.com/roboflow/supervision/pull/1434): [`InferenceSlicer`](https://supervision.roboflow.com/0.23.0/detection/tools/inference_slicer/) now features an `overlap_wh` parameter, making it easier to compute slice sizes when handling overlapping slices.

- Fix [#1448](https://github.com/roboflow/supervision/pull/1448): Various annotator type issues have been resolved, supporting expanded error handling.
- Fixed [#1448](https://github.com/roboflow/supervision/pull/1448): Various annotator type issues have been resolved, supporting expanded error handling.

- Fix [#1348](https://github.com/roboflow/supervision/pull/1348): Introduced a new method for [seeking to a specific video frame](https://supervision.roboflow.com/0.23.0/utils/video/#supervision.utils.video.get_video_frames_generator), addressing cases where traditional seek methods were failing. It can be enabled with `iterative_seek=True`.
- Fixed [#1348](https://github.com/roboflow/supervision/pull/1348): Introduced a new method for [seeking to a specific video frame](https://supervision.roboflow.com/0.23.0/utils/video/#supervision.utils.video.get_video_frames_generator), addressing cases where traditional seek methods were failing. It can be enabled with `iterative_seek=True`.

```python
import supervision as sv
Expand All @@ -572,7 +584,7 @@ for frame in sv.get_video_frames_generator(
...
```

- Fix [#1424](https://github.com/roboflow/supervision/pull/1424): `plot_image` function now clearly indicates that the size is in inches.
- Fixed [#1424](https://github.com/roboflow/supervision/pull/1424): `plot_image` function now clearly indicates that the size is in inches.

!!! failure "Removed"

Expand Down Expand Up @@ -1285,7 +1297,7 @@ array([

### 0.11.1 <small>June 29, 2023</small>

- Fix [#165](https://github.com/roboflow/supervision/pull/165): [`as_folder_structure`](/0.11.1/dataset/core/#supervision.dataset.core.ClassificationDataset.as_folder_structure) fails to save [`sv.ClassificationDataset`](/0.11.1/dataset/core/#classificationdataset) when it is result of inference.
- Fixed [#165](https://github.com/roboflow/supervision/pull/165): [`as_folder_structure`](/0.11.1/dataset/core/#supervision.dataset.core.ClassificationDataset.as_folder_structure) fails to save [`sv.ClassificationDataset`](/0.11.1/dataset/core/#classificationdataset) when it is result of inference.

### 0.11.0 <small>June 28, 2023</small>

Expand Down Expand Up @@ -1331,7 +1343,7 @@ array([

- Added [#162](https://github.com/roboflow/supervision/pull/162): additional `start` and `end` arguments to [`sv.get_video_frames_generator`](/0.11.0/utils/video/#get_video_frames_generator) allowing to generate frames only for a selected part of the video.

- Fix [#157](https://github.com/roboflow/supervision/pull/157): incorrect loading of YOLO dataset class names from `data.yaml`.
- Fixed [#157](https://github.com/roboflow/supervision/pull/157): incorrect loading of YOLO dataset class names from `data.yaml`.

### 0.10.0 <small>June 14, 2023</small>

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "supervision"
description = "A set of easy-to-use utils that will come in handy in any Computer Vision project"
license = { text = "MIT" }
version = "0.26.0"
version = "0.26.1"
readme = "README.md"
requires-python = ">=3.9"
authors = [
Expand Down
7 changes: 5 additions & 2 deletions supervision/annotators/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2239,8 +2239,11 @@ def __init__(
self.position: Position = position
self.color_lookup: ColorLookup = color_lookup

if border_thickness is None:
self.border_thickness = int(0.15 * self.height)
self.border_thickness = (
border_thickness
if border_thickness is not None
else int(0.15 * self.height)
)

@ensure_cv2_image_for_annotation
def annotate(
Expand Down
8 changes: 4 additions & 4 deletions supervision/detection/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1939,8 +1939,8 @@ def with_nms(
class_agnostic (bool): Whether to perform class-agnostic
non-maximum suppression. If True, the class_id of each detection
will be ignored. Defaults to False.
overlap_metric (OverlapMetric): Metric used for measuring overlap between
detections in slices.
overlap_metric (OverlapMetric): Metric used to compute the degree of
overlap between pairs of masks or boxes (e.g., IoU, IoS).

Returns:
Detections: A new Detections object containing the subset of detections
Expand Down Expand Up @@ -2003,8 +2003,8 @@ def with_nmm(
class_agnostic (bool): Whether to perform class-agnostic
non-maximum merging. If True, the class_id of each detection
will be ignored. Defaults to False.
overlap_metric (OverlapMetric): Metric used for measuring overlap between
detections in slices.
overlap_metric (OverlapMetric): Metric used to compute the degree of
overlap between pairs of masks or boxes (e.g., IoU, IoS).

Returns:
Detections: A new Detections object containing the subset of detections
Expand Down
14 changes: 7 additions & 7 deletions supervision/detection/tools/inference_slicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from supervision.config import ORIENTED_BOX_COORDINATES
from supervision.detection.core import Detections
from supervision.detection.utils.boxes import move_boxes, move_oriented_boxes
from supervision.detection.utils.iou_and_nms import OverlapFilter
from supervision.detection.utils.iou_and_nms import OverlapFilter, OverlapMetric
from supervision.detection.utils.masks import move_masks
from supervision.utils.image import crop_image
from supervision.utils.internal import (
Expand Down Expand Up @@ -75,8 +75,8 @@ class InferenceSlicer:
filtering or merging overlapping detections in slices.
iou_threshold (float): Intersection over Union (IoU) threshold
used when filtering by overlap.
match_metric (str): Metric used for matching detections in slices.
"IOU" or "IOS". Defaults "IOU".
overlap_metric (Union[OverlapMetric, str]): Metric used for matching detections
in slices.
callback (Callable): A function that performs inference on a given image
slice and returns detections.
thread_workers (int): Number of threads for parallel execution.
Expand All @@ -96,7 +96,7 @@ def __init__(
overlap_wh: tuple[int, int] | None = None,
overlap_filter: OverlapFilter | str = OverlapFilter.NON_MAX_SUPPRESSION,
iou_threshold: float = 0.5,
match_metric: str = "IOU",
overlap_metric: OverlapMetric | str = OverlapMetric.IOU,
thread_workers: int = 1,
):
if overlap_ratio_wh is not None:
Expand All @@ -112,7 +112,7 @@ def __init__(

self.slice_wh = slice_wh
self.iou_threshold = iou_threshold
self.match_metric = match_metric
self.overlap_metric = OverlapMetric.from_value(overlap_metric)
self.overlap_filter = OverlapFilter.from_value(overlap_filter)
self.callback = callback
self.thread_workers = thread_workers
Expand Down Expand Up @@ -173,11 +173,11 @@ def callback(image_slice: np.ndarray) -> sv.Detections:
return merged
elif self.overlap_filter == OverlapFilter.NON_MAX_SUPPRESSION:
return merged.with_nms(
threshold=self.iou_threshold, match_metric=self.match_metric
threshold=self.iou_threshold, overlap_metric=self.overlap_metric
)
elif self.overlap_filter == OverlapFilter.NON_MAX_MERGE:
return merged.with_nmm(
threshold=self.iou_threshold, match_metric=self.match_metric
threshold=self.iou_threshold, overlap_metric=self.overlap_metric
)
else:
warnings.warn(
Expand Down
27 changes: 18 additions & 9 deletions supervision/detection/utils/iou_and_nms.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ def box_iou_batch(
`shape = (N, 4)` where `N` is number of true objects.
boxes_detection (np.ndarray): 2D `np.ndarray` representing detection boxes.
`shape = (M, 4)` where `M` is number of detected objects.
overlap_metric (OverlapMetric): Metric used for matching detections in slices.
overlap_metric (OverlapMetric): Metric used to compute the degree of overlap
between pairs of boxes (e.g., IoU, IoS).

Returns:
np.ndarray: Pairwise IoU of boxes from `boxes_true` and `boxes_detection`.
Expand Down Expand Up @@ -381,7 +382,8 @@ def _mask_iou_batch_split(
Args:
masks_true (np.ndarray): 3D `np.ndarray` representing ground-truth masks.
masks_detection (np.ndarray): 3D `np.ndarray` representing detection masks.
overlap_metric (OverlapMetric): Metric used for matching detections in slices.
overlap_metric (OverlapMetric): Metric used to compute the degree of overlap
between pairs of masks (e.g., IoU, IoS).

Returns:
np.ndarray: Pairwise IoU of masks from `masks_true` and `masks_detection`.
Expand Down Expand Up @@ -433,7 +435,8 @@ def mask_iou_batch(
Args:
masks_true (np.ndarray): 3D `np.ndarray` representing ground-truth masks.
masks_detection (np.ndarray): 3D `np.ndarray` representing detection masks.
overlap_metric (OverlapMetric): Metric used for matching detections in slices.
overlap_metric (OverlapMetric): Metric used to compute the degree of overlap
between pairs of masks (e.g., IoU, IoS).
memory_limit (int): memory limit in MB, default is 1024 * 5 MB (5GB).

Returns:
Expand Down Expand Up @@ -492,7 +495,8 @@ def mask_non_max_suppression(
dimensions of each mask.
iou_threshold (float): The intersection-over-union threshold
to use for non-maximum suppression.
overlap_metric (OverlapMetric): Metric used for matching detections in slices.
overlap_metric (OverlapMetric): Metric used to compute the degree of overlap
between pairs of masks (e.g., IoU, IoS).
mask_dimension (int): The dimension to which the masks should be
resized before computing IOU values. Defaults to 640.

Expand Down Expand Up @@ -543,7 +547,8 @@ def box_non_max_suppression(
or `(x_min, y_min, x_max, y_max, score, class)`.
iou_threshold (float): The intersection-over-union threshold
to use for non-maximum suppression.
overlap_metric (OverlapMetric): Metric used for matching detections in slices.
overlap_metric (OverlapMetric): Metric used to compute the degree of overlap
between pairs of boxes (e.g., IoU, IoS).

Returns:
np.ndarray: A boolean array indicating which predictions to keep after n
Expand Down Expand Up @@ -603,7 +608,8 @@ def _group_overlapping_masks(
the predictions.
iou_threshold (float): The intersection-over-union threshold
to use for non-maximum suppression. Defaults to 0.5.
overlap_metric (OverlapMetric): Metric used for matching detections in slices.
overlap_metric (OverlapMetric): Metric used to compute the degree of overlap
between pairs of masks (e.g., IoU, IoS).

Returns:
list[list[int]]: Groups of prediction indices be merged.
Expand Down Expand Up @@ -664,7 +670,8 @@ def mask_non_max_merge(
to use for non-maximum suppression.
mask_dimension (int): The dimension to which the masks should be
resized before computing IOU values. Defaults to 640.
overlap_metric (OverlapMetric): Metric used for matching detections in slices.
overlap_metric (OverlapMetric): Metric used to compute the degree of overlap
between pairs of masks (e.g., IoU, IoS).

Returns:
np.ndarray: A boolean array indicating which predictions to keep after
Expand Down Expand Up @@ -717,7 +724,8 @@ def _group_overlapping_boxes(
and the confidence scores.
iou_threshold (float): The intersection-over-union threshold
to use for non-maximum suppression. Defaults to 0.5.
overlap_metric (OverlapMetric): Metric used for matching detections in slices.
overlap_metric (OverlapMetric): Metric used to compute the degree of overlap
between pairs of boxes (e.g., IoU, IoS).

Returns:
list[list[int]]: Groups of prediction indices be merged.
Expand Down Expand Up @@ -765,7 +773,8 @@ def box_non_max_merge(
detections of different classes to be merged.
iou_threshold (float): The intersection-over-union threshold
to use for non-maximum suppression. Defaults to 0.5.
overlap_metric (OverlapMetric): Metric used for matching detections in slices.
overlap_metric (OverlapMetric): Metric used to compute the degree of overlap
between pairs of boxes (e.g., IoU, IoS).

Returns:
list[list[int]]: Groups of prediction indices be merged.
Expand Down
Loading
Loading