roboflow / supervision

We write your reusable computer vision tools. 💜
https://supervision.roboflow.com
MIT License
23.95k stars 1.79k forks source link

Bug found in ConfusionMatrix.from_detections #1619

Open chiggins2024 opened 1 week ago

chiggins2024 commented 1 week ago

Search before asking

Bug

Issue found in code when producing a confusion matrix for object detection. It seems like the FN was being added incorrectly to the matrix. Here is the code that was problematic for me. When removing the else condition, I was getting the correct TP value. It seems that num_classes, ends up being at the same position detection_classes[matched_detection_idx[j]]

for i, true_class_value in enumerate(true_classes): j = matched_true_idx == i print('sum(j)', sum(j)) if matches.shape[0] > 0 and sum(j) == 1: result_matrix[ true_class_value, detection_classes[matched_detection_idx[j]] ] += 1 # TP else: result_matrix[true_class_value, num_classes] += 1 # FN

Environment

No response

Minimal Reproducible Example

No response

Additional

No response

Are you willing to submit a PR?

LinasKo commented 12 hours ago

Hi @chiggins2024 👋

Thank you for the report. We'll check it as soon as we can! As we're transitioning away from the legacy MeanAveragePrecision and ConfusionMatrix, most likely the fix will come as a new ConfusionMatrix version.