From edc4dd33b0c6ac8f2f32d5babfe3c38881a34a79 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:26:51 +0000 Subject: [PATCH] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto=20form?= =?UTF-8?q?at=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/detection/overlap_filter.py | 4 +-- .../detection/tools/inference_slicer.py | 28 ++++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/supervision/detection/overlap_filter.py b/supervision/detection/overlap_filter.py index 602ff56b..f51f1dce 100644 --- a/supervision/detection/overlap_filter.py +++ b/supervision/detection/overlap_filter.py @@ -263,9 +263,7 @@ class OverlapFilter(Enum): try: return cls(value) except ValueError: - raise ValueError( - f"Invalid value: {value}. Must be one of {cls.list()}" - ) + raise ValueError(f"Invalid value: {value}. Must be one of {cls.list()}") raise ValueError( f"Invalid value type: {type(value)}. Must be an instance of " f"{cls.__name__} or str." diff --git a/supervision/detection/tools/inference_slicer.py b/supervision/detection/tools/inference_slicer.py index 9cd8bc03..eea597a9 100644 --- a/supervision/detection/tools/inference_slicer.py +++ b/supervision/detection/tools/inference_slicer.py @@ -9,8 +9,11 @@ from supervision.detection.core import Detections from supervision.detection.overlap_filter import OverlapFilter from supervision.detection.utils import move_boxes, move_masks, move_oriented_boxes from supervision.utils.image import crop_image -from supervision.utils.internal import SupervisionWarnings, warn_deprecated, \ - deprecated_parameter +from supervision.utils.internal import ( + SupervisionWarnings, + deprecated_parameter, + warn_deprecated, +) def move_detections( @@ -84,8 +87,8 @@ class InferenceSlicer: new_parameter="overlap_filter", map_function=lambda x: x, warning_message="`{old_parameter}` in `{function_name}` is deprecated and will " - "be remove in `supervision-0.27.0`. Use '{new_parameter}' " - "instead.", + "be remove in `supervision-0.27.0`. Use '{new_parameter}' " + "instead.", ) def __init__( self, @@ -93,9 +96,7 @@ class InferenceSlicer: slice_wh: Tuple[int, int] = (320, 320), 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, + overlap_filter: Union[OverlapFilter, str] = OverlapFilter.NON_MAX_SUPPRESSION, iou_threshold: float = 0.5, thread_workers: int = 1, ): @@ -205,7 +206,7 @@ class InferenceSlicer: resolution_wh: Tuple[int, int], slice_wh: Tuple[int, int], overlap_ratio_wh: Optional[Tuple[float, float]], - overlap_wh: Optional[Tuple[int, int]] + overlap_wh: Optional[Tuple[int, int]], ) -> np.ndarray: """ Generate offset coordinates for slicing an image based on the given resolution, @@ -240,11 +241,13 @@ class InferenceSlicer: overlap_width = ( overlap_wh[0] if overlap_wh is not None - else int(overlap_ratio_wh[0] * slice_width)) + else int(overlap_ratio_wh[0] * slice_width) + ) overlap_height = ( overlap_wh[1] if overlap_wh is not None - else int(overlap_ratio_wh[1] * slice_height)) + else int(overlap_ratio_wh[1] * slice_height) + ) width_stride = slice_width - overlap_width height_stride = slice_height - overlap_height @@ -263,7 +266,7 @@ class InferenceSlicer: @staticmethod def _validate_overlap( overlap_ratio_wh: Optional[Tuple[float, float]], - overlap_wh: Optional[Tuple[int, int]] + overlap_wh: Optional[Tuple[int, int]], ) -> None: if overlap_ratio_wh is not None and overlap_wh is not None: raise ValueError( @@ -279,6 +282,5 @@ class InferenceSlicer: if overlap_wh is not None: if not (overlap_wh[0] > 0 and overlap_wh[1] > 0): raise ValueError( - "Overlap values must be greater than 0. " - f"Received: {overlap_wh}" + "Overlap values must be greater than 0. " f"Received: {overlap_wh}" )