diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index 4beea2ed..74726995 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -275,7 +275,7 @@ def box_non_max_suppression( return keep[sort_index.argsort()] -def _box_non_max_merge_all( +def group_overlapping_boxes( predictions: npt.NDArray[np.float64], iou_threshold: float = 0.5 ) -> List[List[int]]: """ @@ -338,13 +338,13 @@ def box_non_max_merge( Each group may have 1 or more elements. """ if predictions.shape[1] == 5: - return _box_non_max_merge_all(predictions, iou_threshold) + return group_overlapping_boxes(predictions, iou_threshold) category_ids = predictions[:, 5] merge_groups = [] for category_id in np.unique(category_ids): curr_indices = np.where(category_ids == category_id)[0] - merge_class_groups = _box_non_max_merge_all( + merge_class_groups = group_overlapping_boxes( predictions[curr_indices], iou_threshold ) diff --git a/test/detection/test_utils.py b/test/detection/test_utils.py index 9a1fa8c9..b62faa61 100644 --- a/test/detection/test_utils.py +++ b/test/detection/test_utils.py @@ -6,12 +6,12 @@ import pytest from supervision.config import CLASS_NAME_DATA_FIELD from supervision.detection.utils import ( - _box_non_max_merge_all, box_non_max_suppression, calculate_masks_centroids, clip_boxes, filter_polygons_by_area, get_data_item, + group_overlapping_boxes, mask_non_max_suppression, merge_data, move_boxes, @@ -241,14 +241,14 @@ def test_box_non_max_suppression( ), # confidence ], ) -def test_box_non_max_merge( +def test_group_overlapping_boxes( predictions: np.ndarray, iou_threshold: float, expected_result: List[List[int]], exception: Exception, ) -> None: with exception: - result = _box_non_max_merge_all( + result = group_overlapping_boxes( predictions=predictions, iou_threshold=iou_threshold )