Renamed to group_overlapping_boxes

This commit is contained in:
Linas Kondrackis
2024-05-27 16:21:40 +03:00
parent 530e1d01e1
commit 2ee9e08446
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -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
)
+3 -3
View File
@@ -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
)