From 7f3dcaedbd8608c1f2d6d8f751a57af25c1520c5 Mon Sep 17 00:00:00 2001 From: jirka <6035284+Borda@users.noreply.github.com> Date: Tue, 27 Jan 2026 16:48:11 +0100 Subject: [PATCH] Refactor imports for consistency and update deprecated utility usage across modules --- supervision/detection/core.py | 4 ++-- supervision/detection/utils/boxes.py | 2 +- supervision/detection/vlm.py | 2 +- supervision/keypoint/__init__.py | 4 ++-- supervision/keypoint/annotators.py | 2 +- supervision/keypoint/core.py | 2 +- supervision/metrics/detection.py | 2 +- supervision/utils/conversion.py | 2 +- supervision/utils/image.py | 11 +++++------ 9 files changed, 15 insertions(+), 16 deletions(-) diff --git a/supervision/detection/core.py b/supervision/detection/core.py index 37642632..4fca4911 100644 --- a/supervision/detection/core.py +++ b/supervision/detection/core.py @@ -7,6 +7,7 @@ from functools import reduce from typing import Any import numpy as np +from deprecate import deprecated from supervision.config import ( CLASS_NAME_DATA_FIELD, @@ -50,7 +51,6 @@ from supervision.detection.vlm import ( from_qwen_3_vl, validate_vlm_parameters, ) -from deprecate import deprecated from supervision.geometry.core import Position from supervision.utils.internal import get_instance_variables from supervision.validators import validate_detections_fields @@ -819,7 +819,7 @@ class Detections: @classmethod @deprecated( - target=None, + target=None, deprecated_in="0.27.0", remove_in="0.31.0", ) diff --git a/supervision/detection/utils/boxes.py b/supervision/detection/utils/boxes.py index e9b848c9..bd9b6e41 100644 --- a/supervision/detection/utils/boxes.py +++ b/supervision/detection/utils/boxes.py @@ -105,7 +105,7 @@ def denormalize_boxes( xyxy: np.ndarray, resolution_wh: tuple[int, int], normalization_factor: float = 1.0, - normalized_xyxy: np.ndarray = None + normalized_xyxy: np.ndarray = None, ) -> np.ndarray: """ Convert normalized bounding box coordinates to absolute pixel coordinates. diff --git a/supervision/detection/vlm.py b/supervision/detection/vlm.py index a8bbd9d2..3b160cd5 100644 --- a/supervision/detection/vlm.py +++ b/supervision/detection/vlm.py @@ -9,9 +9,9 @@ from enum import Enum from typing import Any import numpy as np +from deprecate import deprecated from PIL import Image -from deprecate import deprecated from supervision.detection.utils.boxes import denormalize_boxes from supervision.detection.utils.converters import polygon_to_mask, polygon_to_xyxy from supervision.validators import validate_resolution diff --git a/supervision/keypoint/__init__.py b/supervision/keypoint/__init__.py index 5e0b8d75..b449f233 100644 --- a/supervision/keypoint/__init__.py +++ b/supervision/keypoint/__init__.py @@ -7,9 +7,9 @@ warnings.warn( stacklevel=2, ) -from supervision.key_points.annotators import ( # noqa: F401 +from supervision.key_points.annotators import ( EdgeAnnotator, VertexAnnotator, VertexLabelAnnotator, ) -from supervision.key_points.core import KeyPoints # noqa: F401 +from supervision.key_points.core import KeyPoints diff --git a/supervision/keypoint/annotators.py b/supervision/keypoint/annotators.py index 06debc81..84c31e53 100644 --- a/supervision/keypoint/annotators.py +++ b/supervision/keypoint/annotators.py @@ -7,7 +7,7 @@ warnings.warn( stacklevel=2, ) -from supervision.key_points.annotators import ( # noqa: F401 +from supervision.key_points.annotators import ( # noqa: F401E402 BaseKeyPointAnnotator, EdgeAnnotator, VertexAnnotator, diff --git a/supervision/keypoint/core.py b/supervision/keypoint/core.py index e7a92e1b..f41ca7b5 100644 --- a/supervision/keypoint/core.py +++ b/supervision/keypoint/core.py @@ -7,4 +7,4 @@ warnings.warn( stacklevel=2, ) -from supervision.key_points.core import KeyPoints # noqa: F401 +from supervision.key_points.core import KeyPoints # noqa: F401E402 diff --git a/supervision/metrics/detection.py b/supervision/metrics/detection.py index 14f4b04c..df17258d 100644 --- a/supervision/metrics/detection.py +++ b/supervision/metrics/detection.py @@ -6,8 +6,8 @@ from dataclasses import dataclass import matplotlib import matplotlib.pyplot as plt import numpy as np - from deprecate import deprecated + from supervision.dataset.core import DetectionDataset from supervision.detection.core import Detections from supervision.detection.utils.iou_and_nms import box_iou_batch diff --git a/supervision/utils/conversion.py b/supervision/utils/conversion.py index 17c1920f..8f57e0dd 100644 --- a/supervision/utils/conversion.py +++ b/supervision/utils/conversion.py @@ -2,8 +2,8 @@ from functools import wraps import cv2 import numpy as np -from PIL import Image from deprecate import deprecated +from PIL import Image from supervision.draw.base import ImageType diff --git a/supervision/utils/image.py b/supervision/utils/image.py index 22da02fa..fe1aca6b 100644 --- a/supervision/utils/image.py +++ b/supervision/utils/image.py @@ -2,18 +2,17 @@ from __future__ import annotations import os import shutil -from typing import Any +from typing import Any, Literal import cv2 import numpy as np import numpy.typing as npt -from PIL import Image -from supervision.geometry.core import Point -from typing_extensions import Literal - from deprecate import deprecated +from PIL import Image + from supervision.annotators.base import ImageType from supervision.draw.color import Color, unify_to_bgr +from supervision.geometry.core import Point from supervision.utils.conversion import ( ensure_cv2_image_for_standalone_function, ) @@ -657,4 +656,4 @@ def create_tiles( titles_background_color: tuple[int, int, int] | Color = Color.from_hex("#D9D9D9"), default_title_placement: Any = "top", ) -> ImageType: - return None \ No newline at end of file + return None