diff --git a/supervision/detection/core.py b/supervision/detection/core.py index 03dbce24..03d82ae0 100644 --- a/supervision/detection/core.py +++ b/supervision/detection/core.py @@ -2052,7 +2052,7 @@ def merge_inner_detections_objects( def merge_inner_detections_objects_without_iou( - detections: List[Detections], + detections: list[Detections], ) -> Detections: """ Given N detections each of length 1 (exactly one object inside), combine them into a diff --git a/supervision/detection/overlap_filter.py b/supervision/detection/overlap_filter.py index fe0076ed..3cace664 100644 --- a/supervision/detection/overlap_filter.py +++ b/supervision/detection/overlap_filter.py @@ -169,7 +169,7 @@ def group_overlapping_boxes( overlap_metric (OverlapMetric): Metric used for matching detections in slices. Returns: - List[List[int]]: Groups of prediction indices be merged. + list[list[int]]: Groups of prediction indices be merged. Each group may have 1 or more elements. """ merge_groups: list[list[int]] = [] @@ -204,7 +204,7 @@ def mask_non_max_merge( iou_threshold: float = 0.5, mask_dimension: int = 640, overlap_metric: OverlapMetric = OverlapMetric.IOU, -) -> List[List[int]]: +) -> list[list[int]]: """ Perform Non-Maximum Merging (NMM) on segmentation predictions. @@ -277,7 +277,7 @@ def box_non_max_merge( overlap_metric (OverlapMetric): Metric used for matching detections in slices. Returns: - List[List[int]]: Groups of prediction indices be merged. + list[list[int]]: Groups of prediction indices be merged. Each group may have 1 or more elements. """ if predictions.shape[1] == 5: @@ -307,7 +307,7 @@ def group_overlapping_masks( masks: npt.NDArray[np.float64], iou_threshold: float = 0.5, overlap_metric: OverlapMetric = OverlapMetric.IOU, -) -> List[List[int]]: +) -> list[list[int]]: """ Apply greedy version of non-maximum merging to avoid detecting too many @@ -322,10 +322,10 @@ def group_overlapping_masks( overlap_metric (OverlapMetric): Metric used for matching detections in slices. Returns: - List[List[int]]: Groups of prediction indices be merged. + list[list[int]]: Groups of prediction indices be merged. Each group may have 1 or more elements. """ - merge_groups: List[List[int]] = [] + merge_groups: list[list[int]] = [] scores = predictions[:, 4] order = scores.argsort() diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index 1fff408a..eba62509 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -2,7 +2,7 @@ from __future__ import annotations from enum import Enum from itertools import chain -from typing import Any, Optional, Union +from typing import Any import cv2 import numpy as np diff --git a/test/detection/test_overlap_filter.py b/test/detection/test_overlap_filter.py index c1c6c5e2..f655f0e9 100644 --- a/test/detection/test_overlap_filter.py +++ b/test/detection/test_overlap_filter.py @@ -620,7 +620,7 @@ def test_mask_non_max_merge( predictions: np.ndarray, masks: np.ndarray, iou_threshold: float, - expected_result: List[List[int]], + expected_result: list[list[int]], exception: Exception, ) -> None: with exception: