Skip to content

Top 1 accuracy for detection metrics #928

Closed

Description

@christuchez

In detection models, some classes can look very similar, which often leads to overlapping bounding boxes for the same object. In these cases, precision and recall don't give us the full picture, because what we really need to know is how often the model assigns the correct class, i.e., the top-1 accuracy for each class.

Would it be possible to add the following to validation?

Top-1 accuracy for highly overlapping boxes: An option to calculate top-1 accuracy when predicted boxes overlap above a configurable IoU threshold, where the top-1 prediction is the box with the highest confidence score. It should also be possible to specify which classes this runs for.

Per-class metrics at multiple confidence thresholds: A breakdown of precision, recall, and F1 score for each class across a range of confidence thresholds.

These additions would make it much easier to evaluate how well the model distinguishes between similar-looking classes and to choose the right confidence thresholds for deployment for each class.

Activity

  1. added a commit that references this issue on Oct 3, 2026
  2. EHxuban11 commented on Oct 3, 2026

    @EHxuban11
    Contributor

    Hello @christuchez , thank you for the interesting and detailed request.

    You are right that it's not possible to do what you are asking for. This is why I took a look at the YOLO api and realized that a few things are missing in libreyolo...

    I've worked on this PR which is now merged: #931

    With it, you can get what you want in two steps:

    • Run validation with this new flag: agnostic_nms=True which will run the nms on the bounding boxes ignoring the classes. You can use classes= to limit it to certain classes.
    • Then you can read results.confusion_matrix.class_accuracy() to get per class, how often a found object gets the right class, which is the top-1 accuracy.

    For the per class precision, recall and F1 at multiple confidence thresholds use the new results.box.p_curve, r_curve and f1_curve in results.box.px.

    Thank you for the issue, I hope that this satisfies your request. I know that I didn't implement exactly what you asked for but I'm trying to keep it compatible with the YOLO api standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions