@@ -299,7 +299,9 @@ def evaluate_detection_batch(
299
299
if len (targets ) == 0 :
300
300
# No ground truth - all detections are FP
301
301
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
+ )
303
305
for det_class in detection_classes :
304
306
result_matrix [num_classes , det_class ] += 1
305
307
return result_matrix
@@ -316,9 +318,11 @@ def evaluate_detection_batch(
316
318
# print("Debug IoU calculations:")
317
319
# print(f"GT boxes: {true_boxes}")
318
320
# print(f"Detection boxes: {detection_boxes}")
319
-
321
+
320
322
# 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
+ )
322
326
# print(f"IoU matrix:\n{iou_batch}")
323
327
324
328
# Find all valid matches (IoU > threshold, regardless of class)
@@ -329,7 +333,7 @@ def evaluate_detection_batch(
329
333
if iou > iou_threshold :
330
334
gt_class = true_classes [gt_idx ]
331
335
det_class = detection_classes [det_idx ]
332
- class_match = ( gt_class == det_class )
336
+ class_match = gt_class == det_class
333
337
valid_matches .append ((gt_idx , det_idx , iou , class_match ))
334
338
# print(f"Valid match: GT[{gt_idx}] class={gt_class} vs Det[{det_idx}] class={det_class}, IoU={iou:.3f}, class_match={class_match}")
335
339
@@ -341,7 +345,7 @@ def evaluate_detection_batch(
341
345
# Greedily assign matches, ensuring each GT and detection is matched at most once
342
346
matched_gt_idx = set ()
343
347
matched_det_idx = set ()
344
-
348
+
345
349
for gt_idx , det_idx , iou , class_match in valid_matches :
346
350
if gt_idx not in matched_gt_idx and det_idx not in matched_det_idx :
347
351
# Valid spatial match - record the class prediction
0 commit comments