fix(pre_commit): 🎨 auto format pre-commit hooks

This commit is contained in:
pre-commit-ci[bot] 2025-07-15 17:25:55 +00:00
parent fa5fcbb264
commit 592a649b50
17 changed files with 110 additions and 73 deletions

View File

@ -46,35 +46,11 @@ from supervision.detection.line_zone import (
LineZoneAnnotator,
LineZoneAnnotatorMulticlass,
)
from supervision.detection.utils.iou_and_nms import (
box_iou,
box_iou_batch,
box_iou_batch_with_jaccard,
oriented_box_iou_batch,
mask_iou_batch,
OverlapFilter,
OverlapMetric,
box_non_max_merge,
box_non_max_suppression,
mask_non_max_suppression,
)
from supervision.detection.utils.masks import (
move_masks,
calculate_masks_centroids,
contains_holes,
contains_multiple_segments
)
from supervision.detection.utils.converters import (
xcycwh_to_xyxy,
xywh_to_xyxy,
xyxy_to_polygons,
xyxy_to_xcycarh,
xyxy_to_xywh,
mask_to_polygons,
mask_to_xyxy,
polygon_to_mask,
polygon_to_xyxy,
)
from supervision.detection.tools.csv_sink import CSVSink
from supervision.detection.tools.inference_slicer import InferenceSlicer
from supervision.detection.tools.json_sink import JSONSink
from supervision.detection.tools.polygon_zone import PolygonZone, PolygonZoneAnnotator
from supervision.detection.tools.smoother import DetectionsSmoother
from supervision.detection.utils.boxes import (
clip_boxes,
denormalize_boxes,
@ -82,15 +58,39 @@ from supervision.detection.utils.boxes import (
pad_boxes,
scale_boxes,
)
from supervision.detection.utils.polygons import (
filter_polygons_by_area,
approximate_polygon
from supervision.detection.utils.converters import (
mask_to_polygons,
mask_to_xyxy,
polygon_to_mask,
polygon_to_xyxy,
xcycwh_to_xyxy,
xywh_to_xyxy,
xyxy_to_polygons,
xyxy_to_xcycarh,
xyxy_to_xywh,
)
from supervision.detection.utils.iou_and_nms import (
OverlapFilter,
OverlapMetric,
box_iou,
box_iou_batch,
box_iou_batch_with_jaccard,
box_non_max_merge,
box_non_max_suppression,
mask_iou_batch,
mask_non_max_suppression,
oriented_box_iou_batch,
)
from supervision.detection.utils.masks import (
calculate_masks_centroids,
contains_holes,
contains_multiple_segments,
move_masks,
)
from supervision.detection.utils.polygons import (
approximate_polygon,
filter_polygons_by_area,
)
from supervision.detection.tools.csv_sink import CSVSink
from supervision.detection.tools.inference_slicer import InferenceSlicer
from supervision.detection.tools.json_sink import JSONSink
from supervision.detection.tools.polygon_zone import PolygonZone, PolygonZoneAnnotator
from supervision.detection.tools.smoother import DetectionsSmoother
from supervision.detection.vlm import LMM, VLM
from supervision.draw.color import Color, ColorPalette
from supervision.draw.utils import (
@ -192,6 +192,7 @@ __all__ = [
"VertexLabelAnnotator",
"VideoInfo",
"VideoSink",
"approximate_polygon",
"box_iou",
"box_iou_batch",
"box_iou_batch_with_jaccard",
@ -244,5 +245,4 @@ __all__ = [
"xyxy_to_polygons",
"xyxy_to_xcycarh",
"xyxy_to_xywh",
"approximate_polygon"
]

View File

@ -22,10 +22,12 @@ from supervision.annotators.utils import (
)
from supervision.config import ORIENTED_BOX_COORDINATES
from supervision.detection.core import Detections
from supervision.detection.utils.boxes import spread_out_boxes, clip_boxes
from supervision.detection.utils.converters import mask_to_polygons, xyxy_to_polygons, \
polygon_to_mask
from supervision.detection.utils.boxes import clip_boxes, spread_out_boxes
from supervision.detection.utils.converters import (
mask_to_polygons,
polygon_to_mask,
xyxy_to_polygons,
)
from supervision.draw.color import Color, ColorPalette
from supervision.draw.utils import draw_polygon, draw_rounded_rectangle, draw_text
from supervision.geometry.core import Point, Position, Rect

View File

@ -15,7 +15,6 @@ from supervision.dataset.utils import (
from supervision.detection.core import Detections
from supervision.detection.utils.converters import polygon_to_mask
from supervision.detection.utils.masks import contains_holes, contains_multiple_segments
from supervision.utils.file import read_json_file, save_json_file
if TYPE_CHECKING:

View File

@ -13,8 +13,10 @@ import numpy.typing as npt
from supervision.detection.core import Detections
from supervision.detection.utils.converters import mask_to_polygons
from supervision.detection.utils.polygons import filter_polygons_by_area, \
approximate_polygon
from supervision.detection.utils.polygons import (
approximate_polygon,
filter_polygons_by_area,
)
if TYPE_CHECKING:
from supervision.dataset.core import DetectionDataset

View File

@ -18,15 +18,23 @@ from supervision.detection.tools.transformers import (
process_transformers_v5_segmentation_result,
)
from supervision.detection.utils.converters import mask_to_xyxy, xywh_to_xyxy
from supervision.detection.utils.internal import get_data_item, is_data_equal, \
is_metadata_equal, extract_ultralytics_masks, process_roboflow_result, merge_data, \
merge_metadata
from supervision.detection.utils.internal import (
extract_ultralytics_masks,
get_data_item,
is_data_equal,
is_metadata_equal,
merge_data,
merge_metadata,
process_roboflow_result,
)
from supervision.detection.utils.iou_and_nms import (
OverlapMetric,
box_iou_batch,
box_non_max_merge,
box_non_max_suppression,
mask_iou_batch,
mask_non_max_merge,
mask_non_max_suppression, mask_iou_batch, box_iou_batch,
mask_non_max_suppression,
)
from supervision.detection.utils.masks import calculate_masks_centroids
from supervision.detection.vlm import (

View File

@ -82,4 +82,4 @@ def approximate_polygon(
else:
break
return np.squeeze(approximated_points, axis=1)
return np.squeeze(approximated_points, axis=1)

View File

@ -9,9 +9,11 @@ from matplotlib import pyplot as plt
from supervision.config import ORIENTED_BOX_COORDINATES
from supervision.detection.core import Detections
from supervision.detection.utils.iou_and_nms import box_iou_batch, mask_iou_batch, \
oriented_box_iou_batch
from supervision.detection.utils.iou_and_nms import (
box_iou_batch,
mask_iou_batch,
oriented_box_iou_batch,
)
from supervision.draw.color import LEGACY_COLOR_PALETTE
from supervision.metrics.core import AveragingMethod, Metric, MetricTarget
from supervision.metrics.utils.object_size import (

View File

@ -9,9 +9,11 @@ from matplotlib import pyplot as plt
from supervision.config import ORIENTED_BOX_COORDINATES
from supervision.detection.core import Detections
from supervision.detection.utils.iou_and_nms import box_iou_batch, mask_iou_batch, \
oriented_box_iou_batch
from supervision.detection.utils.iou_and_nms import (
box_iou_batch,
mask_iou_batch,
oriented_box_iou_batch,
)
from supervision.draw.color import LEGACY_COLOR_PALETTE
from supervision.metrics.core import Metric, MetricTarget
from supervision.metrics.utils.object_size import (

View File

@ -9,8 +9,11 @@ from matplotlib import pyplot as plt
from supervision.config import ORIENTED_BOX_COORDINATES
from supervision.detection.core import Detections
from supervision.detection.utils.iou_and_nms import box_iou_batch, mask_iou_batch, \
oriented_box_iou_batch
from supervision.detection.utils.iou_and_nms import (
box_iou_batch,
mask_iou_batch,
oriented_box_iou_batch,
)
from supervision.draw.color import LEGACY_COLOR_PALETTE
from supervision.metrics.core import AveragingMethod, Metric, MetricTarget
from supervision.metrics.utils.object_size import (

View File

@ -9,9 +9,11 @@ from matplotlib import pyplot as plt
from supervision.config import ORIENTED_BOX_COORDINATES
from supervision.detection.core import Detections
from supervision.detection.utils.iou_and_nms import box_iou_batch, mask_iou_batch, \
oriented_box_iou_batch
from supervision.detection.utils.iou_and_nms import (
box_iou_batch,
mask_iou_batch,
oriented_box_iou_batch,
)
from supervision.draw.color import LEGACY_COLOR_PALETTE
from supervision.metrics.core import AveragingMethod, Metric, MetricTarget
from supervision.metrics.utils.object_size import (

View File

@ -6,8 +6,8 @@ import numpy as np
import pytest
from supervision.detection.core import Detections
from supervision.detection.utils.iou_and_nms import OverlapFilter
from supervision.detection.tools.inference_slicer import InferenceSlicer
from supervision.detection.utils.iou_and_nms import OverlapFilter
@pytest.fixture

View File

@ -141,4 +141,4 @@ def test_scale_boxes(
) -> None:
with exception:
result = scale_boxes(xyxy=xyxy, factor=factor)
assert np.array_equal(result, expected_result)
assert np.array_equal(result, expected_result)

View File

@ -3,8 +3,12 @@ from __future__ import annotations
import numpy as np
import pytest
from supervision.detection.utils.converters import xywh_to_xyxy, xyxy_to_xywh, \
xyxy_to_xcycarh, xcycwh_to_xyxy
from supervision.detection.utils.converters import (
xcycwh_to_xyxy,
xywh_to_xyxy,
xyxy_to_xcycarh,
xyxy_to_xywh,
)
@pytest.mark.parametrize(
@ -124,4 +128,4 @@ def test_xyxy_to_xcycarh(xyxy: np.ndarray, expected_result: np.ndarray) -> None:
)
def test_xcycwh_to_xyxy(xcycwh: np.ndarray, expected_result: np.ndarray) -> None:
result = xcycwh_to_xyxy(xcycwh)
np.testing.assert_array_equal(result, expected_result)
np.testing.assert_array_equal(result, expected_result)

View File

@ -7,8 +7,12 @@ import numpy as np
import pytest
from supervision.config import CLASS_NAME_DATA_FIELD
from supervision.detection.utils.internal import process_roboflow_result, merge_data, \
get_data_item, merge_metadata
from supervision.detection.utils.internal import (
get_data_item,
merge_data,
merge_metadata,
process_roboflow_result,
)
TEST_MASK = np.zeros((1, 1000, 1000), dtype=bool)
TEST_MASK[:, 300:351, 200:251] = True
@ -245,6 +249,7 @@ def test_process_roboflow_result(
f"Mismatch in non-array data for key {key}"
)
@pytest.mark.parametrize(
"data_list, expected_result, exception",
[

View File

@ -5,8 +5,12 @@ from contextlib import ExitStack as DoesNotRaise
import numpy as np
import pytest
from supervision.detection.utils.iou_and_nms import box_non_max_suppression, \
mask_non_max_suppression, mask_non_max_merge, _group_overlapping_boxes
from supervision.detection.utils.iou_and_nms import (
_group_overlapping_boxes,
box_non_max_suppression,
mask_non_max_merge,
mask_non_max_suppression,
)
@pytest.mark.parametrize(

View File

@ -6,8 +6,12 @@ import numpy as np
import numpy.typing as npt
import pytest
from supervision.detection.utils.masks import move_masks, calculate_masks_centroids, \
contains_holes, contains_multiple_segments
from supervision.detection.utils.masks import (
calculate_masks_centroids,
contains_holes,
contains_multiple_segments,
move_masks,
)
@pytest.mark.parametrize(

View File

@ -99,4 +99,4 @@ def test_filter_polygons_by_area(
)
assert len(result) == len(expected_result)
for result_polygon, expected_result_polygon in zip(result, expected_result):
assert np.array_equal(result_polygon, expected_result_polygon)
assert np.array_equal(result_polygon, expected_result_polygon)