cancel
Showing results for 
Search instead for 
Did you mean: 

Help with deploying multi-class YOLOv8n (80-class) model on STM32N6-DK

Doouv
Associate II

Hello community,

I am currently working on deploying a full YOLOv8n (80-class COCO) model on the STM32N6570-DK and integrating it with the Object Detection example from the STM32 AI Model Zoo Service.

I closely followed this tutorial:
How to deploy YOLOv8/YOLOv5 Object Detection models

and used the official quantization scripts here:
YOLOv8 Quantization Scripts


Model & Quantization Setup

  • Base model: yolov8n.pt (Ultralytics official)

  • Exported to: SavedModel format

  • Quantization: done per STM32AI model zoo tutorial

  • Input: uint8 (0–255)

  • Output tested as:

    1. uint8 input / float output

    2. uint8 input / int8 output

Case Input Type Output Type Result

(1)

uint8floatIncorrect inference — bounding boxes & class scores both wrong
(2)uint8int8Bounding boxes coordinates always same (incorrect), classification correct

After debugging case (2), I found:

  • The bounding box coordinates remain constant across frames and detections, even before post-processing.

  • The output tensors are quantized correctly, but the model’s raw outputs (prior to postprocess) seem fixed.

  • The default post-process used in the deployment script (deploy.py) is set for INT8 output models (POSTPROCESS_OD_YOLO_V8_UI). (Permalink)

When we changed this manually to POSTPROCESS_OD_YOLO_V8_UF (for float output) in the STM32N6 Object Detection app and reflashed, the results remained incorrect.


Thank you in advance for your help and guidance

 

6 REPLIES 6
Julian E.
ST Employee

Hi @Doouv,

 

This is the yaml I use to deploy the yolov8 model for people detection from ultralytics.

Could you try to edit it to add your 80 classes and see if it deploys correctly with model zoo services?

 

If yes, then you will find the source code in stm32ai-modelzoo-services\application_code\object_detection\STM32N6\Application\STM32N6570-DK

 

Else, please share your model in .zip. I will ask the dev team to see if they can take a look.

 

Have a good day,

Julian


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi @Julian E. 

I did try out and played around with the given yaml but got same results(no inference).
I , for now , am trying to get 256x256 multiclass yolov8n model running but my final objective is to get 640x480 multiclass yolov8n running.
PFA models for 256x256 input resolution

Thank you



Hi @Doouv,

 

What are the classes of the model you attached? 

I will try to deploy it on my side.

 

Have a good day,

Julian


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi @Julian E. 

I am trying to implement the same 80 classes as in Yolov8n trained on COCO dataset

 

class_names: ["person","bicycle","car","motorcycle","airplane","bus","train","truck","boat","traffic light","fire hydrant","stop sign","parking meter","bench","bird","cat","dog","horse","sheep","cow","elephant","bear","zebra","giraffe","backpack","umbrella","handbag","tie","suitcase","frisbee","skis","snowboard","sports ball","kite","baseball bat","baseball glove","skateboard","surfboard","tennis racket","bottle","wine glass","cup","fork","knife","spoon","bowl","banana","apple","sandwich","orange","broccoli","carrot","hot dog","pizza","donut","cake","chair","couch","potted plant","bed","dining table","toilet","tv","laptop","mouse","remote","keyboard","cell phone","microwave","oven","toaster","sink","refrigerator","book","clock","vase","scissors","teddy bear","hair drier","toothbrush"]

Thanks

Hi @Doouv,

 

I deployed your yolov8n_256_quant_pc_uf_od_coco500.tflite model on the N6. 

The model seems to run, but I have wrong bounding boxes. I don't know if it comes from your model or from the firmware.

When I deploy yolov8n_320_quant_pc_uf_od_coco-person.tflite from model zoo, using the same scripts, I have a correct inference...

 

I attached the yaml I used. In the case of the model from model zoo, to deploy it, just replace your 80 classes by ["person"].

 

Let me know if you at least succeed to deploy the model from model zoo.

 

Have a good day,

Julian


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi @Julian E. 

I myself was able to replicate implementation of model from the STM32-AI model zoo and it worked perfectly.

However these models are limited to single class ("person") , I want to add on more classes hence I simply quantized a pretrained original yolov8n model(80 classes) by following the below documentation.
https://github.com/STMicroelectronics/stm32ai-modelzoo-services/tree/main/tutorials/scripts/yolov8_quantization

The model I provided earlier(yolov8n_256_quant_pc_uf_od_coco500.tflite) is the output from the above without any unnecessary changes and hinderance.

It would be great if I can get some help in implementing multiclass yolov8n model on STM32N6-DK.

Link to YOLOv8n - https://docs.ultralytics.com/models/yolov8/#detection-coco

Python code for Model export-

from ultralytics import YOLO

model = YOLO("yolov8n.pt")
model.export(format="saved_model", imgsz=256, int8=True)


Thanks