Skip to content

Bug found in ConfusionMatrix.from_detections #1619

@chiggins2024

Description

@chiggins2024

Search before asking

  • I have searched the Supervision issues and found no similar bug report.

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?

  • Yes I'd like to help by submitting a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions