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

This commit is contained in:
pre-commit-ci[bot] committed 2025-04-24 23:33:17 +00:00
1 parent 29695055d2
commit a6aa9b7d3b
3 files changed
+29 -21

No files matched your search

+7 -7
View File
@@ -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(
+16 -10
View File
@@ -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)
+6 -4
View File
@@ -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)