I trained a custom Yolo v8 classification model on 2 classes. When i run the model on my laptop it classifies images correctly, so the problem is most likely not in the dataset. I used depthai library as interface for oak camera. I converted the model from .pt format to required blob format using http://blobconverter.luxonis.com/. When i deploy the converted model to oak camera using the depthai, the model always classifies the images as the class number 1. I guess that there is a certain loss of data or parameters in the conversion process, because classification works correctly in .pt format on my laptop as i mentioned before.
I tried using http://tools.luxonis.com/ website but it only supports detection, and not classification when it comes to Yolo v8. I also tried to use the export command that Yolo v8 offers and exported the model in the Intermediate Format(IR), and then convert it to blob format using the same tool http://blobconverter.luxonis.com/. Weirdly, the model now always classified the images as class number 2.

I wonder if there is another tool i could use, or am i doing something wrong in the conversion process?

What is confusing about 'detection only' mentioned near Yolov8?

Nothing is confusing, I just mentioned that I could not use that tool for conversion because my model is trained for classification. I need a way to convert my model correctly.

I was trying to say 'it tells you it won't work, so why do you think it will?'. It doesn't have to do with conversion, it has to do with depthai not working with Yolov8 except for detection - you are reading the warning incorrectly.

Okay, sorry, I did not realise at first what you meant. Can you suggest me any other framework that I could use to train image classification model, but that has the ability to work with depthai, unlike Yolov8.

    2 months later

    Hi aleksajanjic99

    I'm just curious have you solved this problem? I am also using YOLOV5s classification model to do my work, and finding the classified results are just way worse than what I got by running the trained model on host (which means I didn't run my model on OAK-D camera). Cannot really figure this out.

    Also I'd like to know your thoughts Jaka jakaskerl. In another person's post I asked a related question, and Matija thought it could be that I used an improper way to retrieve classified results from the last layer of my model (like I shouldn't use softmax to get my classifications). I am a bit confused because all the classification examples I could find online are using a softmax to get their results finally. In addition, I don't understand how do my inaccurate results have anything to do with softmax

    To verify that my model can work well but just something wrong with configuration on OAK, I ran my classification model on my host, and it happened to be good. A part of my code is like below:

        # Inference with YOLOv5
        with torch.no_grad():
            results = model(img_tensor)
            
        # Convert the logits to percentages using softmax
        probs = F.softmax(results, dim=1)
            
        # Get class with highest confidence
        confidences, class_idx = probs.squeeze(0).max(0)
        label = f'{class_names[class_idx]} {confidences:.2f}'

    Glad to know your thoughts on this problem.

    Cheers,

    Austin

    • erik replied to this.
      6 months later

      --data_type=FP16 --mean_values=[127.5,127.5,127.5] --scale_values=[255,255,255]--reverse_input_channels

      This made no difference for me. My Yolo classification model is still inaccurate @erik

      @userOfCamera
      The values depend of how your model was trained. Either the values are incorrect for your model, or the model doesn't work at all.

      @jakaskerl I was able to figure out the flags which correctly converted my model (it is accurate now, tested on OAK with DepthAI and on my webcam normally)

      The flags I used to convert my YOLO model on the blob converter tool:

      --data_type=FP16 --scale_values=[255,255,255] --reverse_input_channels