From a6aa9b7d3be8099c158a95a7a9324412d86ef059 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 24 Apr 2025 23:33:11 +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/annotators/core.py | 14 +++++++------- supervision/annotators/utils.py | 26 ++++++++++++++++---------- supervision/detection/utils.py | 10 ++++++---- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index 5190fa21..f10491ff 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -1110,9 +1110,7 @@ class LabelAnnotator(_BaseLabelAnnotator): validate_labels(labels, detections) labels = get_labels_text(detections, labels) - label_properties = self._get_label_properties( - detections, labels - ) + label_properties = self._get_label_properties(detections, labels) if self.smart_position: xyxy = label_properties[:, :4] @@ -1176,10 +1174,12 @@ class LabelAnnotator(_BaseLabelAnnotator): position=self.text_anchor, ) - label_properties.append([ - *text_background_xyxy, - total_height, - ]) + label_properties.append( + [ + *text_background_xyxy, + total_height, + ] + ) return np.array(label_properties).reshape(-1, 5) def _draw_labels( diff --git a/supervision/annotators/utils.py b/supervision/annotators/utils.py index 48ee1ecb..8406bb5d 100644 --- a/supervision/annotators/utils.py +++ b/supervision/annotators/utils.py @@ -293,19 +293,23 @@ def snap_boxes(xyxy: np.ndarray, resolution_wh: Tuple[int, int]) -> np.ndarray: shift_if_left_out = -result[:, 0] shift_if_right_out = width - result[:, 2] - shift_x = np.where(result[:, 0] < 0, shift_if_left_out, - np.where(result[:, 2] > width, shift_if_right_out, 0)) + shift_x = np.where( + result[:, 0] < 0, + shift_if_left_out, + np.where(result[:, 2] > width, shift_if_right_out, 0), + ) result[:, 0] += shift_x result[:, 2] += shift_x - shift_if_top_out = -result[:, 1] shift_if_bottom_out = height - result[:, 3] - shift_y = np.where(result[:, 1] < 0, shift_if_top_out, - np.where(result[:, 3] > height, shift_if_bottom_out, 0)) - + shift_y = np.where( + result[:, 1] < 0, + shift_if_top_out, + np.where(result[:, 3] > height, shift_if_bottom_out, 0), + ) result[:, 1] += shift_y result[:, 3] += shift_y @@ -331,10 +335,12 @@ class Trace: def put(self, detections: Detections) -> None: frame_id = np.full(len(detections), self.current_frame_id, dtype=int) self.frame_id = np.concatenate([self.frame_id, frame_id]) - self.xy = np.concatenate([ - self.xy, - detections.get_anchors_coordinates(self.anchor), - ]) + self.xy = np.concatenate( + [ + self.xy, + detections.get_anchors_coordinates(self.anchor), + ] + ) self.tracker_id = np.concatenate([self.tracker_id, detections.tracker_id]) unique_frame_id = np.unique(self.frame_id) diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index 8949537e..8f1019e9 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -1264,10 +1264,12 @@ def cross_product(anchors: np.ndarray, vector: Vector) -> np.ndarray: Returns: Array of cross products of shape (number of anchors, detections) """ - vector_at_zero = np.array([ - vector.end.x - vector.start.x, - vector.end.y - vector.start.y, - ]) + vector_at_zero = np.array( + [ + vector.end.x - vector.start.x, + vector.end.y - vector.start.y, + ] + ) vector_start = np.array([vector.start.x, vector.start.y]) return np.cross(vector_at_zero, anchors - vector_start)