Skip to main content
Associate
September 12, 2025
Solved

STM32MPU25 object detection model failing to run python scripts

  • September 12, 2025
  • 2 replies
  • 1357 views

Hi

I am using STM32MPU25 to evaluate object detection, when i use stai_mpu_object_detection binary to run default ssd_mobilenet_v2 models , i can see object detection works.

when i run python scripts to launch application( example : launch_bin_object_detection_testdata.sh) i see below error.

root@stm32mp25-discounknownunknown:/usr/local/x-linux-ai/object-detection# sh launch_python_object_detection.sh
stai_mpu wrapper used :
machine used = stm32mp2x with GPU/NPU
user : weston
-sh: /usr/local/x-linux-ai/object-detection/stai_mpu_object_detection.py: Permission denied

 

i assume it may be due to weston user and root user.

so i copied all objection detection samples to /home/weston and gave appropriate permissions and change user to weston and launch application, i see below errors.

^^^^^^^^^^^^^^^^^^^^^
File "/home/weston/test/Application/ssd_mobilenet_pp.py", line 129, in get_results
return locations, classes, scores
^^^^^^^^^
UnboundLocalError: cannot access local variable 'locations' where it is not associated with a value
Traceback (most recent call last):
File "/home/weston/test//Application/object_detection.py", line 336, in new_sample
self.app.nn_result_locations, self.app.nn_result_classes, self.app.nn_result_scores = self.nn.get_results()
^^^^^^^^^^^^^^^^^^^^^
File "/home/weston/test/Application/ssd_mobilenet_pp.py", line 129, in get_results
return locations, classes, scores

can you point to environment where i can evaluate object detection models ( i followed procedure at https://github.com/STMicroelectronics/stm32ai-modelzoo-services/tree/main/object_detection  to create object detection model  with custom data set and deploy into stm32mpu25)

 

Thanks

 

Best answer by akr1

Adding background class started detecting objects properly in stm32mpu257.

couple of questions i have 

1) while running launch_python_object_detection.sh  i see below error

while running  File "/home/weston/object-detection//Application/object_detection.py", line 679, in drawing
y0 = int(self.app.nn_result_locations[0][i][1] * preview_height)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: index 3 is out of bounds for axis 0 with size 3
Traceback (most recent call last):
File "/home/weston/object-detection//Application/object_detection.py", line 679, in drawing
y0 = int(self.app.nn_result_locations[0][i][1] * preview_height)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: index 3 is out of bounds for axis 0 with size 3
Traceback (most recent call last):
File "/home/weston/object-detection//Application/object_detection.py", line 679, in drawing
y0 = int(self.app.nn_result_locations[0][i][1] * preview_height)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: index 3 is out of bounds for axis 0 with size 3 

 

2) does tiny yolo work in stm32mpu25 for object detection , if it works can you point to README or any documentation ?

2 replies

Julian E.
Technical Moderator
September 22, 2025

Hello @akr1,

 

Could you share your OSTL and X linux AI version please?

 

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.
akr1Author
Associate
September 24, 2025

Hi ,

 

I am able to run objection detection now  . when i use deployment script  to deploy into target and changing scripts permissions accordingly in target.

but while running objection detection model i see below error and bounding boxes are not accurate.

Is input_shape: (224, 224, 3) is good for ssd_mobilenet_v2_fpnlite for object detection?

Same custom model runs fine when doing prediction in host pc with test images and all bounding boxes are shown correctly.

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: index 2 is out of bounds for axis 0 with size 1
Traceback (most recent call last):
File "/home/weston/object-detection//Application/object_detection.py", line 679, in drawing
y0 = int(self.app.nn_result_locations[0][i][1] * preview_height)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: index 2 is out of bounds for axis 0 with size 2
Traceback (most recent call last):
File "/home/weston/object-detection//Application/object_detection.py", line 679, in drawing
y0 = int(self.app.nn_result_locations[0][i][1] * preview_height)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: index 2 is out of bounds for axis 0 with size 2

Julian E.
Technical Moderator
September 25, 2025

Hello @akr1,

 

We need your OSTL and X linux AI version to help you.

Are you using the provided model or your own?

 

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.
Julian E.
Technical Moderator
October 6, 2025

Hello @akr1,

 

Could you share your model (in .zip), so that I can ask the dev team to look at the issue here.

 

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.
akr1Author
Associate
October 6, 2025

Hi,

 

Attached models zip file.

Thanks

Julian E.
Technical Moderator
October 7, 2025

Hello @akr1,

 

The dev team gave me feedback; here is what should be done:

  1. You need to create a .txt with your classes, for example "labels_custom.txt".
    The class "background" should be first.
  2. Change your model's name for it to include "ssd_mobilenet_v2", for example "ssd_mobilenet_v2_custom.nb". 
    The scripts look for the kind of model used to apply the right preprocessing.

 

Then in  launch_python_object_detection.sh, edit the model and label:

  • $OBJ_DETEC_MODEL  --> ssd_mobilenet_v2_custom.nb 
  • $OBJ_DETEC_MODEL_LABEL.txt --> custom_label.txt

 

This should help.

In case you had already done that, please share some examples images for us to test.

Seeing your classes, we did not really understand what the classes were and how to test them.

 

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.