From 145b5fe56c1b1daec6e8161fece90a5f23155c76 Mon Sep 17 00:00:00 2001 From: Linas Kondrackis Date: Wed, 15 May 2024 10:46:56 +0300 Subject: [PATCH] Rename to batch_box_non_max_merge to box_non_max_merge_batch --- supervision/__init__.py | 2 +- supervision/detection/core.py | 4 ++-- supervision/detection/utils.py | 8 +------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/supervision/__init__.py b/supervision/__init__.py index 3eae2e17..03f52086 100644 --- a/supervision/__init__.py +++ b/supervision/__init__.py @@ -43,9 +43,9 @@ from supervision.detection.tools.json_sink import JSONSink from supervision.detection.tools.polygon_zone import PolygonZone, PolygonZoneAnnotator from supervision.detection.tools.smoother import DetectionsSmoother from supervision.detection.utils import ( - batch_box_non_max_merge, box_iou_batch, box_non_max_merge, + box_non_max_merge_batch, box_non_max_suppression, calculate_masks_centroids, clip_boxes, diff --git a/supervision/detection/core.py b/supervision/detection/core.py index 76224bb7..2489ef80 100644 --- a/supervision/detection/core.py +++ b/supervision/detection/core.py @@ -8,9 +8,9 @@ import numpy as np from supervision.config import CLASS_NAME_DATA_FIELD, ORIENTED_BOX_COORDINATES from supervision.detection.utils import ( - batch_box_non_max_merge, box_iou_batch, box_non_max_merge, + box_non_max_merge_batch, box_non_max_suppression, calculate_masks_centroids, extract_ultralytics_masks, @@ -1226,7 +1226,7 @@ class Detections: self.class_id.reshape(-1, 1), ) ) - keep_to_merge_list = batch_box_non_max_merge(predictions, threshold) + keep_to_merge_list = box_non_max_merge_batch(predictions, threshold) result = [] for keep_ind, merge_ind_list in keep_to_merge_list.items(): diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index f6308f57..c159de59 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -300,18 +300,12 @@ def box_non_max_merge( y2 = predictions[:, 3] scores = predictions[:, 4] - areas = (x2 - x1) * (y2 - y1) order = scores.argsort() - keep = [] - while len(order) > 0: idx = order[-1] - - keep.append(idx.tolist()) - order = order[:-1] if len(order) == 0: @@ -353,7 +347,7 @@ def box_non_max_merge( return keep_to_merge_list -def batch_box_non_max_merge( +def box_non_max_merge_batch( predictions: np.ndarray, iou_threshold: float = 0.5 ) -> Dict[int, List[int]]: """