cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with deploying object detection project on STM32N6-DK

cosard
Associate II

Hello,

I am trying to test a deployed application for object detection.

I have tested out of the box object detection application code.

I can successfully build the project and I can run the code on my board.

Unfortunately it doesn't detect any objects. It is supposed to detect person but it never detected.

I have tried to use different pre-trained models and built and run them successfully but none of them work.

The screen shows the live camera image, shows inference value and detected object number is always zero.

Is there anything that I miss?

 

By the way, the factory demo AI application works perfectly, it successfully detects people. So the hardware is OK.

19 REPLIES 19
Julian E.
ST Employee

Hello @cosard ,

 

Could you describe more what you do please:

  • Are you using the getting started as a standalone or with model zoo
  • Which tutorial are you following
  • Which model are you trying to deploy

 

If you are using the standalone getting started, when doing the stedgeai generate, please try adding a few options:

stedgeai generate --model your_model.tflite --target stm32n6 --st-neural-art default@user_neuralart.json --input-data-type uint8 --inputs-ch-position chlast

 

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,

Thank you for your response.

 

I first downloaded the application code from ST website.

I downloaded both n6-ai-getstarted and n6-ai-pdetect projects.

I built both as separate projects in CubeIDE and run them on STM32N6570-DK board.

I was not able to detect any Person objects.

 

Also I have followed the tutorial in

https://github.com/STMicroelectronics/stm32ai-modelzoo-services/blob/main/object_detection/deployment/README_STM32N6.md#2

After following all the steps there the stm32ai.py command updates the project that we provided as application code inside the modelzoo-services folder. 

I have flashed the code through the generated CubeIDE project.

 

I tried different trained models such as 

ssd_mobilenet_v2_fpnlite_035_192_int8.tflite

st_yolo_x_nano_192_0.33_0.25_int8.tflite

st_ssd_mobilenet_v1_025_192/st_ssd_mobilenet_v1_025_192_int8.tflite

tiny_yolo_v2_224_int8.tflite

tiny_yolo_v2_416_int8.tflite

 

and generated the project with the command below.

python stm32ai_main.py --config-path ./config_file_examples/ --config-name deployment_xx.yaml

 

Could you how can I provide a json file with the command you have provided

 

stedgeai generate --model your_model.tflite --target stm32n6 --st-neural-art default@user_neuralart.json --input-data-type uint8 --inputs-ch-position chlast

 

Thanks.

Hello @cosard ,

 

Thank you for the information.

The command I send you is to use instead as replacement when you follow the Deploy-your-tflite-Model.md in the getting_started/STM32N6/object_detection/Doc

 

But I think it is easier to do it with model zoo.

Can you send me the output of your terminal when running the stm32ai_main.py please.

 

When switching the boot pin from left to right or the other way around, make sure to unplug the N6 and plug it again

 

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,

 

Here is the output of the terminal when I run stm32ai_main.py

 

[INFO] : Running `deployment` operation mode
[INFO] : A URL found for general.model_path variable!
[INFO] : Pretrained model file downloaded successfully and saved as :
	/Users/cosardindar/Projects/techsols/STM32N6/stm32ai-modelzoo-services/object_detection/src/experiments_outputs/2025_03_13_01_42_26/pretrained_model/yolov8n_192_quant_pc_uf_od_coco-person-st.tflite
2025/03/13 01:42:28 WARNING mlflow.utils.autologging_utils: You are using an unsupported version of tensorflow. If you encounter errors during autologging, try upgrading / downgrading tensorflow to a supported version, or try upgrading MLflow.
[INFO] : The random seed for this simulation is 123
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
[INFO] : Generating C header file for Getting Started...
loading model.. model_path="/Users/cosardindar/Projects/techsols/STM32N6/stm32ai-modelzoo-services/object_detection/src/experiments_outputs/2025_03_13_01_42_26/pretrained_model/yolov8n_192_quant_pc_uf_od_coco-person-st.tflite"
loading conf file.. "../../application_code/object_detection/STM32N6/stmaic_STM32N6570-DK.conf" config="None"
"n6 release" configuration is used
[INFO] : Selected board :  "STM32N6570-DK Getting Started Object Detection (STM32CubeIDE)" (stm32_cube_ide/n6 release/stm32n6)
[INFO] : Compiling the model and generating optimized C code + Lib/Inc files:  /Users/cosardindar/Projects/techsols/STM32N6/stm32ai-modelzoo-services/object_detection/src/experiments_outputs/2025_03_13_01_42_26/pretrained_model/yolov8n_192_quant_pc_uf_od_coco-person-st.tflite
setting STM.AI tools.. root_dir="", req_version=""
 Cube AI Path: "/Applications/ST/STEdgeAI/2.0/Utilities/macarm/stedgeai".
[INFO] : Offline CubeAI used; Selected tools:  10.0.0 (x-cube-ai pack)
loading conf file.. "../../application_code/object_detection/STM32N6/stmaic_STM32N6570-DK.conf" config="None"
"n6 release" configuration is used
compiling... "yolov8n_192_quant_pc_uf_od_coco-person-st_tflite" session
 model_path  : ['/Users/cosardindar/Projects/techsols/STM32N6/stm32ai-modelzoo-services/object_detection/src/experiments_outputs/2025_03_13_01_42_26/pretrained_model/yolov8n_192_quant_pc_uf_od_coco-person-st.tflite']
 tools       : 10.0.0 (x-cube-ai pack)
 target      : "STM32N6570-DK Getting Started Object Detection (STM32CubeIDE)" (stm32_cube_ide/n6 release/stm32n6)
 options     : --st-neural-art default@../../application_code/object_detection/STM32N6/Model/user_neuralart.json --input-data-type uint8 --inputs-ch-position chlast
"series" value is not coherent.. stm32n6 != stm32n6npu
 results -> RAM=714,240 IO=110,592:15,120 WEIGHTS=3,046,497 MACC=0 RT_RAM=1,893 RT_FLASH=454,783 LATENCY=0.000
[INFO] : Optimized C code + Lib/Inc files generation done.
[INFO] : Building the STM32 c-project..
deploying the c-project.. "STM32N6570-DK Getting Started Object Detection (STM32CubeIDE)" (stm32_cube_ide/n6 release/stm32n6)
updating.. n6 release
 -> s:copying file.. "network.c" to ../../application_code/object_detection/STM32N6/Model/network.c
 -> s:copying file.. "network_ecblobs.h" to ../../application_code/object_detection/STM32N6/Model/network_ecblobs.h
 -> s:copying file.. "network_atonbuf.xSPI2.raw" to ../../application_code/object_detection/STM32N6/Model/network_atonbuf.xSPI2.raw
 -> s:removing dir.. ../../application_code/object_detection/STM32N6/Middlewares/AI_Runtime/Lib/GCC/ARMCortexM55
 -> s:copying dir.. "ARMCortexM55" to ../../application_code/object_detection/STM32N6/Middlewares/AI_Runtime/Lib/GCC/ARMCortexM55
 -> s:removing dir.. ../../application_code/object_detection/STM32N6/Middlewares/AI_Runtime/Inc
 -> s:copying dir.. "Inc" to ../../application_code/object_detection/STM32N6/Middlewares/AI_Runtime/Inc
 -> s:removing dir.. ../../application_code/object_detection/STM32N6/Middlewares/AI_Runtime/Npu/ll_aton
 -> s:copying dir.. "ll_aton" to ../../application_code/object_detection/STM32N6/Middlewares/AI_Runtime/Npu/ll_aton
 -> u:copying file.. "app_config.h" to ../../application_code/object_detection/STM32N6/Inc/app_config.h
 -> updating cproject file "/Users/cosardindar/Projects/techsols/STM32N6/stm32ai-modelzoo-services/application_code/object_detection/STM32N6/STM32CubeIDE" with "NetworkRuntime1000_CM55_GCC.a"
building.. n6 release
flashing.. n6 release STM32N6570-DK
[returned code = 127 - FAILED]
[INFO] deployment complete

 

Everything seems to be good except flashing.

I am flashing the board through CubeIDE from the generated project.

I am running the code from the RAM, the boot pins are both H level.

 

Thanks,

Cosar.

@cosard, I should have asked this also, sorry, can you send me the config.yaml you used to get this.

Thanks

 

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.

Sure. Here is the config.yaml file content below.

general:
  model_path: https://github.com/stm32-hotspot/ultralytics/raw/refs/heads/main/examples/YOLOv8-STEdgeAI/stedgeai_models/object_detection/yolov8n_192_quant_pc_uf_od_coco-person-st.tflite 
  model_type: yolo_v8
operation_mode: deployment

dataset:
   class_names: [person]

preprocessing:
  resizing:
    aspect_ratio: crop
    interpolation: nearest
  color_mode: rgb

postprocessing:
  confidence_thresh: 0.6
  NMS_thresh: 0.5
  IoU_eval_thresh: 0.4
  max_detection_boxes: 10

tools:
  stedgeai:
    version: 10.0.0
    optimization: balanced
    on_cloud: False
    path_to_stedgeai: /Applications/ST/STEdgeAI/2.0/Utilities/macarm/stedgeai
  path_to_cubeIDE: /Applications/STM32CubeIDE.app/Contents/MacOS/STM32CubeIDE

deployment:
  c_project_path: ../../application_code/object_detection/STM32N6/
  IDE: GCC
  verbosity: 1
  hardware_setup:
    serie: STM32N6
    board: STM32N6570-DK #STM32H747I-DISCO, STM32N6570-DK

mlflow:
   uri: ./experiments_outputs/mlruns

hydra:
   run:
      dir: ./experiments_outputs/${now:%Y_%m_%d_%H_%M_%S}

Hello @cosard ,

 

Everything seems correct.... I don't really have an explanation for now

I do not have access to a N6 until tuesday next week.

 

In the meantime, my guess is:

  • Maybe there is an issue with our code when using a url as model path. Based on the logs, it seems to work but I have never done it. Can you try to use a local path for the model path?
  • Are you sure you have a data cable? It should be quite thick (I don't think there is really a way to know other than that).
  • You confirm that you are plugging your board with the ST link port on the right?

 

To confirm one thing, what you do is as follow, right?

  1. Set the pins of the N6 to the right
  2. Plug the N6 (after setting the boot pins)
  3. Activate the virtual env (if you used one when installing model zoo)
  4. Running stm32ai_main.py
  5. Setting the boot pin to the left and unplug/plug the N6 again

 

Sorry for the time it will take to help you..

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.

Hello @Julian E. 

 

Alright it would be great if you can try it out on your STM32N65-DK board whenever possible for you.

  • I have tested the code with 8-10 different models. Most of them are in local, only a few of them are based on URL in the config.yaml. With all models I am not able to detect any object. The flashing is not done through stm32ai_main.py call, maybe due to it doesn't work on macos. So I flash the code through the updated CubeIDE project. I can verify the code has been updated from the welcomescreen message at startup. It writes the defined model name in config.yaml on the welcomescreen message.
  • I am using a USB-C to USB-C data cable and I connect it to a USB-C and the cable has a good quality I don't think there might be an issue with it. 
  •  The jumpers (BOOT0 and BOOT1) are on the right side (to the USB-C jack) when I am flashing and running the test code.

 

The test code should be running in RAM since when I switch the boot pins to left side and reset the board I see the demo firmware is running and when I switch boot pins back to the right side there is no code is running.

Having the boot pins at the right, I flash the project and run it then I can see the test code is running on the DK board. The live camera data is streamed to the LCD screen and there are inference value and the number of detected objects written on the screen. Inference value changes a bit but detected object number is always zero.

Inference value is high in some models and it is low in some of them.

 

Thank you,

Cosar.

Julian E.
ST Employee

Hello @cosard ,

 

Can you try to reduce the thresholds to something low like 0.01:

postprocessing:
  confidence_thresh: 0.01
  NMS_thresh: 0.01
  IoU_eval_thresh: 0.01
  max_detection_boxes: 10

The goal is to see it you can manage to display green bounding boxes, even if totally wrong.

 

I'll keep you updated.

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.