Skip to content

Commit 5743494

Browse files
fix(pre_commit): 🎨 auto format pre-commit hooks
1 parent 65411ae commit 5743494

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

‎supervision/metrics/detection.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ def evaluate_detection_batch(
299299
if len(targets) == 0:
300300
# No ground truth - all detections are FP
301301
class_id_idx = 4
302-
detection_classes = np.array(detection_batch_filtered[:, class_id_idx], dtype=np.int16)
302+
detection_classes = np.array(
303+
detection_batch_filtered[:, class_id_idx], dtype=np.int16
304+
)
303305
for det_class in detection_classes:
304306
result_matrix[num_classes, det_class] += 1
305307
return result_matrix
@@ -316,9 +318,11 @@ def evaluate_detection_batch(
316318
# print("Debug IoU calculations:")
317319
# print(f"GT boxes: {true_boxes}")
318320
# print(f"Detection boxes: {detection_boxes}")
319-
321+
320322
# Calculate IoU matrix
321-
iou_batch = box_iou_batch(boxes_true=true_boxes, boxes_detection=detection_boxes)
323+
iou_batch = box_iou_batch(
324+
boxes_true=true_boxes, boxes_detection=detection_boxes
325+
)
322326
# print(f"IoU matrix:\n{iou_batch}")
323327

324328
# Find all valid matches (IoU > threshold, regardless of class)
@@ -329,7 +333,7 @@ def evaluate_detection_batch(
329333
if iou > iou_threshold:
330334
gt_class = true_classes[gt_idx]
331335
det_class = detection_classes[det_idx]
332-
class_match = (gt_class == det_class)
336+
class_match = gt_class == det_class
333337
valid_matches.append((gt_idx, det_idx, iou, class_match))
334338
# print(f"Valid match: GT[{gt_idx}] class={gt_class} vs Det[{det_idx}] class={det_class}, IoU={iou:.3f}, class_match={class_match}")
335339

@@ -341,7 +345,7 @@ def evaluate_detection_batch(
341345
# Greedily assign matches, ensuring each GT and detection is matched at most once
342346
matched_gt_idx = set()
343347
matched_det_idx = set()
344-
348+
345349
for gt_idx, det_idx, iou, class_match in valid_matches:
346350
if gt_idx not in matched_gt_idx and det_idx not in matched_det_idx:
347351
# Valid spatial match - record the class prediction

0 commit comments

Comments
 (0)