From f4048eeede8d414b6416f9fa14686b510ca4d69b Mon Sep 17 00:00:00 2001 From: Iuri de Silvio Date: Sun, 14 Jul 2024 11:13:36 +0200 Subject: [PATCH] Replace deprecated `BoundingBoxAnnotator` with `BoxAnnotator` --- inference/core/interfaces/stream/sinks.py | 8 ++++---- inference_cli/lib/infer_adapter.py | 6 +++--- .../tile_detections_batch.py | 2 +- .../tile_detections_non_batch.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/inference/core/interfaces/stream/sinks.py b/inference/core/interfaces/stream/sinks.py index ff8e41bfe7..2795d46c96 100644 --- a/inference/core/interfaces/stream/sinks.py +++ b/inference/core/interfaces/stream/sinks.py @@ -17,7 +17,7 @@ from inference.core.utils.drawing import create_tiles from inference.core.utils.preprocess import letterbox_image -DEFAULT_BBOX_ANNOTATOR = sv.BoundingBoxAnnotator() +DEFAULT_BBOX_ANNOTATOR = sv.BoxAnnotator() DEFAULT_LABEL_ANNOTATOR = sv.LabelAnnotator() DEFAULT_FPS_MONITOR = sv.FPSMonitor() @@ -50,7 +50,7 @@ def render_boxes( """ Helper tool to render object detection predictions on top of video frame. It is designed to be used with `InferencePipeline`, as sink for predictions. By default it uses - standard `sv.BoundingBoxAnnotator()` chained with `sv.LabelAnnotator()` + standard `sv.BoxAnnotator()` chained with `sv.LabelAnnotator()` to draw bounding boxes and resizes prediction to 1280x720 (keeping aspect ratio and adding black padding). One may configure default behaviour, for instance to display latency and throughput statistics. In batch mode it will display tiles of frames and overlay predictions. @@ -69,7 +69,7 @@ def render_boxes( by `VideoSource` or list of frames from (it is possible for empty batch frames at corresponding positions to `predictions` list). Order is expected to match with `predictions` annotator (Union[BaseAnnotator, List[BaseAnnotator]]): instance of class inheriting from supervision BaseAnnotator - or list of such instances. If nothing is passed chain of `sv.BoundingBoxAnnotator()` and `sv.LabelAnnotator()` is used. + or list of such instances. If nothing is passed chain of `sv.BoxAnnotator()` and `sv.LabelAnnotator()` is used. display_size (Tuple[int, int]): tuple in format (width, height) to resize visualisation output fps_monitor (Optional[sv.FPSMonitor]): FPS monitor used to monitor throughput display_statistics (bool): Flag to decide if throughput and latency can be displayed in the result image, @@ -419,7 +419,7 @@ def init( Args: video_file_name (str): name of the video file to save predictions annotator (Union[BaseAnnotator, List[BaseAnnotator]]): instance of class inheriting from supervision BaseAnnotator - or list of such instances. If nothing is passed chain of `sv.BoundingBoxAnnotator()` and `sv.LabelAnnotator()` is used. + or list of such instances. If nothing is passed chain of `sv.BoxAnnotator()` and `sv.LabelAnnotator()` is used. display_size (Tuple[int, int]): tuple in format (width, height) to resize visualisation output. Should be set to the same value as `display_size` for InferencePipeline with single video source, otherwise it represents the size of single visualisation tile (whole tiles mosaic will be scaled to diff --git a/inference_cli/lib/infer_adapter.py b/inference_cli/lib/infer_adapter.py index 68b3d655b1..98bcf95843 100644 --- a/inference_cli/lib/infer_adapter.py +++ b/inference_cli/lib/infer_adapter.py @@ -8,7 +8,7 @@ import numpy as np from supervision import ( BlurAnnotator, - BoundingBoxAnnotator, + BoxAnnotator, BoxCornerAnnotator, ByteTrack, CircleAnnotator, @@ -46,7 +46,7 @@ ) ANNOTATOR_TYPE2CLASS = { - "bounding_box": BoundingBoxAnnotator, + "bounding_box": BoxAnnotator, "mask": MaskAnnotator, "polygon": PolygonAnnotator, "color": ColorAnnotator, @@ -313,7 +313,7 @@ def is_something_to_do( def build_visualisation_callback( visualisation_config: Optional[str], ) -> Callable[[np.ndarray, dict], Optional[np.ndarray]]: - annotators = [BoundingBoxAnnotator()] + annotators = [BoxAnnotator()] byte_tracker = None if visualisation_config is not None: raw_configuration = retrieve_visualisation_config( diff --git a/tests/workflows/integration_tests/execution/stub_plugins/dimensionality_manipulation_plugin/tile_detections_batch.py b/tests/workflows/integration_tests/execution/stub_plugins/dimensionality_manipulation_plugin/tile_detections_batch.py index 31c13e0edb..326d300f79 100644 --- a/tests/workflows/integration_tests/execution/stub_plugins/dimensionality_manipulation_plugin/tile_detections_batch.py +++ b/tests/workflows/integration_tests/execution/stub_plugins/dimensionality_manipulation_plugin/tile_detections_batch.py @@ -84,7 +84,7 @@ async def run( images_crops: Batch[Batch[WorkflowImageData]], crops_predictions: Batch[Batch[sv.Detections]], ) -> BlockResult: - annotator = sv.BoundingBoxAnnotator() + annotator = sv.BoxAnnotator() visualisations = [] for image_crops, crop_predictions in zip(images_crops, crops_predictions): visualisations_batch_element = [] diff --git a/tests/workflows/integration_tests/execution/stub_plugins/dimensionality_manipulation_plugin/tile_detections_non_batch.py b/tests/workflows/integration_tests/execution/stub_plugins/dimensionality_manipulation_plugin/tile_detections_non_batch.py index bf9e3aa2b1..23ca6121df 100644 --- a/tests/workflows/integration_tests/execution/stub_plugins/dimensionality_manipulation_plugin/tile_detections_non_batch.py +++ b/tests/workflows/integration_tests/execution/stub_plugins/dimensionality_manipulation_plugin/tile_detections_non_batch.py @@ -80,7 +80,7 @@ async def run( crops: Batch[WorkflowImageData], crops_predictions: Batch[sv.Detections], ) -> BlockResult: - annotator = sv.BoundingBoxAnnotator() + annotator = sv.BoxAnnotator() visualisations = [] for image, prediction in zip(crops, crops_predictions): annotated_image = annotator.annotate(