From 23023e9764a01307a60e8a6eb204bbc6cde93a89 Mon Sep 17 00:00:00 2001 From: LinasKo Date: Tue, 1 Oct 2024 13:22:55 +0300 Subject: [PATCH] Revert default overlap_ratio_wh value, update docs --- docs/changelog.md | 2 +- supervision/detection/tools/inference_slicer.py | 9 +++++---- test/detection/tools/test_inference_slicer.py | 4 +--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 0acf99ec..d4e4faf1 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -96,7 +96,7 @@ detections = sv.Detections.from_sam(sam_result=sam_result) - Added [#1409](https://github.com/roboflow/supervision/pull/1409): `text_color` option for [`VertexLabelAnnotator`](https://supervision.roboflow.com/0.23.0/keypoint/annotators/#supervision.keypoint.annotators.VertexLabelAnnotator) keypoint annotator. -- Changed [#1434](https://github.com/roboflow/supervision/pull/1434): [`InferenceSlicer`](https://supervision.roboflow.com/0.23.0/detection/tools/inference_slicer/) now features an `overlap_ratio_wh` parameter, making it easier to compute slice sizes when handling overlapping slices. +- Changed [#1434](https://github.com/roboflow/supervision/pull/1434): [`InferenceSlicer`](https://supervision.roboflow.com/0.23.0/detection/tools/inference_slicer/) now features an `overlap_wh` parameter, making it easier to compute slice sizes when handling overlapping slices. - Fix [#1448](https://github.com/roboflow/supervision/pull/1448): Various annotator type issues have been resolved, supporting expanded error handling. diff --git a/supervision/detection/tools/inference_slicer.py b/supervision/detection/tools/inference_slicer.py index 68455015..81092fe8 100644 --- a/supervision/detection/tools/inference_slicer.py +++ b/supervision/detection/tools/inference_slicer.py @@ -60,7 +60,8 @@ class InferenceSlicer: Args: slice_wh (Tuple[int, int]): Dimensions of each slice measured in pixels. The tuple should be in the format `(width, height)`. - overlap_ratio_wh (Optional[Tuple[float, float]]): A tuple representing the + overlap_ratio_wh (Optional[Tuple[float, float]]): [⚠️ Deprecated: please set + to `None` and use `overlap_wh`] A tuple representing the desired overlap ratio for width and height between consecutive slices. Each value should be in the range [0, 1), where 0 means no overlap and a value close to 1 means high overlap. @@ -87,14 +88,14 @@ class InferenceSlicer: new_parameter="overlap_filter", map_function=lambda x: x, warning_message="`{old_parameter}` in `{function_name}` is deprecated and will " - "be removed in `supervision-0.27.0`. Use '{new_parameter}' " - "instead.", + "be removed in `supervision-0.27.0`. Please set to `None` and use " + "'{new_parameter}' instead.", ) def __init__( self, callback: Callable[[np.ndarray], Detections], slice_wh: Tuple[int, int] = (320, 320), - overlap_ratio_wh: Optional[Tuple[float, float]] = None, + overlap_ratio_wh: Optional[Tuple[float, float]] = (0.2, 0.2), overlap_wh: Optional[Tuple[int, int]] = None, overlap_filter: Union[OverlapFilter, str] = OverlapFilter.NON_MAX_SUPPRESSION, iou_threshold: float = 0.5, diff --git a/test/detection/tools/test_inference_slicer.py b/test/detection/tools/test_inference_slicer.py index cccecfc2..812e7941 100644 --- a/test/detection/tools/test_inference_slicer.py +++ b/test/detection/tools/test_inference_slicer.py @@ -13,9 +13,7 @@ from supervision.detection.tools.inference_slicer import InferenceSlicer def mock_callback(): """Mock callback function for testing.""" - def callback(image_slice: np.ndarray) -> Detections: - # Here we mock the detection process, returning a mock detection - # Assume detections are just coordinates for simplicity + def callback(_: np.ndarray) -> Detections: return Detections(xyxy=np.array([[0, 0, 10, 10]])) return callback