Hello,

I've finetuned a YOLOv8 nano classification model, and am using it with an OAK 1 PoE to classify an image into one of six categories.

The classification works fine on those items, but the greatest issue I'm facing is that when something that isn't one of the 6 categories shows up, the model still gives it a percentage out of those six categories.

I want to implement a confidence threshold, or be able to classify the items as 'None' (I'm assuming a confidence threshold is the best way to do this).

There's info online on how to set a conf threshold when predicting with YOLO directly. How can I do this through DepthAI (my custom model is a Neural Network Node)? I want less false positives

Hi @userOfCamera
You can set the confidence threshold using detectionNetwork.setConfidenceThreshold() or you can manually discard detection messages if their confidence is less than some threshold. This allows you to do it per label basis. More info: https://docs.luxonis.com/projects/api/en/latest/components/messages/img_detections/#imgdetections

Though I'd suggest training a model with the 7th class being none.

Thanks,
Jaka

    jakaskerl I don't have an object detection yolo model - I'm using an Image Classification YOLO model. When I changed it from a NeuralNet node to a YoloObjectDetection node, the output detections were just a blank array

      14 days later

      userOfCamera

      Hey, sorry for a late reply.

      If you have a classification model, your output will be an array of values. Check if softmax is included in the network or not, you can easily see this if the values sum up to 1. If they don't, you have to apply softmax operation to the array after you get them out of the network.

      Typically, in classification problems, you will take the value that is the highest, and this will be your predicted class. If you want to add some additional thresholding, you can simply check if this confidence value is higher than your threshold. If it's not, you would say that there is no valid prediction.