Skip to content

Commit c8c9783

Browse files
Removing unnecessary comments
1 parent 8d2354a commit c8c9783

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

supervision/metrics/detection.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,9 @@ def evaluate_detection_batch(
311311
)
312312
true_boxes = targets[:, :class_id_idx]
313313
detection_boxes = detection_batch_filtered[:, :class_id_idx]
314-
315-
# # Debug: Print IoU calculations
316-
# print("Debug IoU calculations:")
317-
# print(f"GT boxes: {true_boxes}")
318-
# print(f"Detection boxes: {detection_boxes}")
319314

320315
# Calculate IoU matrix
321316
iou_batch = box_iou_batch(boxes_true=true_boxes, boxes_detection=detection_boxes)
322-
# print(f"IoU matrix:\n{iou_batch}")
323317

324318
# Find all valid matches (IoU > threshold, regardless of class)
325319
valid_matches = []
@@ -331,14 +325,10 @@ def evaluate_detection_batch(
331325
det_class = detection_classes[det_idx]
332326
class_match = (gt_class == det_class)
333327
valid_matches.append((gt_idx, det_idx, iou, class_match))
334-
# print(f"Valid match: GT[{gt_idx}] class={gt_class} vs
335-
# Det[{det_idx}] class={det_class}, IoU={iou:.3f},
336-
# class_match={class_match}")
337328

338329
# Sort matches by class match first (True before False), then by IoU descending
339330
# This prioritizes correct class predictions over higher IoU with wrong class
340331
valid_matches.sort(key=lambda x: (x[3], x[2]), reverse=True)
341-
# print(f"Sorted matches: {valid_matches}")
342332

343333
# Greedily assign matches, ensuring each GT
344334
# and detection is matched at most once
@@ -350,8 +340,7 @@ def evaluate_detection_batch(
350340
# Valid spatial match - record the class prediction
351341
gt_class = true_classes[gt_idx]
352342
det_class = detection_classes[det_idx]
353-
# print(f"Assigning match: GT[{gt_idx}] class={gt_class} ->
354-
# Det[{det_idx}] class={det_class}")
343+
355344
# This handles both correct classification (TP) and misclassification
356345
result_matrix[gt_class, det_class] += 1
357346
matched_gt_idx.add(gt_idx)
@@ -360,16 +349,13 @@ def evaluate_detection_batch(
360349
# Count unmatched ground truth as FN
361350
for gt_idx, gt_class in enumerate(true_classes):
362351
if gt_idx not in matched_gt_idx:
363-
# print(f"Unmatched GT[{gt_idx}] class={gt_class} -> FN")
364352
result_matrix[gt_class, num_classes] += 1
365353

366354
# Count unmatched detections as FP
367355
for det_idx, det_class in enumerate(detection_classes):
368356
if det_idx not in matched_det_idx:
369-
# print(f"Unmatched Det[{det_idx}] class={det_class} -> FP")
370357
result_matrix[num_classes, det_class] += 1
371-
372-
# print(f"Final matrix:\n{result_matrix}")
358+
373359
return result_matrix
374360

375361
@staticmethod

0 commit comments

Comments
 (0)