diff --git a/supervision/detection/core.py b/supervision/detection/core.py index cdaf00d0..a74c2669 100644 --- a/supervision/detection/core.py +++ b/supervision/detection/core.py @@ -1586,8 +1586,8 @@ class Detections: 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 matching detections - in slices. + overlap_metric (OverlapMetric): Metric used for measuring overlap between + detections in slices. Returns: Detections: A new Detections object containing the subset of detections @@ -1624,13 +1624,13 @@ class Detections: predictions=predictions, masks=self.mask, iou_threshold=threshold, - match_metric=overlap_metric, + overlap_metric=overlap_metric, ) else: indices = box_non_max_suppression( predictions=predictions, iou_threshold=threshold, - match_metric=overlap_metric, + overlap_metric=overlap_metric, ) return self[indices] @@ -1650,8 +1650,8 @@ class Detections: 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 matching detections in slices. - "IOU" or "IOS". Defaults "IOU". + overlap_metric (OverlapMetric): Metric used for measuring overlap between + detections in slices. Returns: Detections: A new Detections object containing the subset of detections @@ -1690,13 +1690,13 @@ class Detections: predictions=predictions, masks=self.mask, iou_threshold=threshold, - match_metric=overlap_metric, + overlap_metric=overlap_metric, ) else: merge_groups = box_non_max_merge( predictions=predictions, iou_threshold=threshold, - match_metric=overlap_metric, + overlap_metric=overlap_metric, ) result = [] @@ -1803,7 +1803,9 @@ def merge_inner_detection_object_pair( def merge_inner_detections_objects( - detections: List[Detections], threshold=0.5, match_metric: str = "IOU" + detections: List[Detections], + threshold=0.5, + overlap_metric: OverlapMetric = OverlapMetric.IOU, ) -> Detections: """ Given N detections each of length 1 (exactly one object inside), combine them into a @@ -1816,9 +1818,11 @@ def merge_inner_detections_objects( detections_1 = detections[0] for detections_2 in detections[1:]: if detections_1.mask is not None and detections_2.mask is not None: - iou = mask_iou_batch(detections_1.mask, detections_2.mask, match_metric)[0] + iou = mask_iou_batch(detections_1.mask, detections_2.mask, overlap_metric)[ + 0 + ] else: - iou = box_iou_batch(detections_1.xyxy, detections_2.xyxy, match_metric)[0] + iou = box_iou_batch(detections_1.xyxy, detections_2.xyxy, overlap_metric)[0] if iou < threshold: break detections_1 = merge_inner_detection_object_pair(detections_1, detections_2)