cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with AI Model Validation on STM32H747I-DISCO

Dresult
Associate II

 

Hi everyone,

I'm trying to perform a validation test on an STM32H747I-DISCO, but I haven't been able to get it working.

Here's what I'm doing:

  1. On the ST Edge AI Developer Cloud, I select the model "CNN2D_ST_HandPosture_8classes_hand_posture_ST_VL53L5CX_handposture_dataset.h5", then proceed to quantize and optimize it.
  2. I run a benchmark and then download the project for STM32CubeMX 6.14.
  3. I open the project and, in the Software Packs, I select "Device Application" for the M7 core and enable the "Validation" option under STMicroelectronics.X-CUBE-AI. I then save the project.
  4. Next, I open the generated project in STM32CubeIDE 1.18, compile the code for the M7 and M4 cores in Release mode, and program the STM board. So far, everything works fine. When I press the reset button I can see 
#
# AI Validation 7.1
#
Compiled with GCC 13.3.1
STM32 device configuration...
 Device       : DevID:0x0450 (STM32H743/53/50xx and STM32H745/55/47/57xx) RevID:0x2003
 Core Arch.   : M7 - FPU  used
 HAL version  : 0x010b0500
 SYSCLK clock : 400 MHz
 HCLK clock   : 200 MHz
 FLASH conf.  : ACR=0x00000032 - latency=2
 CACHE conf.  : $I/$D=(True,True)
 Timestamp    : SysTick + DWT (delay(1)=1.002 ms)

ST.AI RT
--------------------------------------------------
 tools version   : v2.0.0
 network rt lib  : v10.0.0-fd22b7f9
   compiled with : GCC 11.3.1

Discovering the network(s)...

Found network "network"
Creating the network "network"..
Initializing the network
Network informations...
 model name         : network
 model signature    : 0x8f1b6d2aab7b9895e6460ef525012bb0
 model datetime     : 2025-03-23T17:34:47+0100
 compile datetime   : Mar 23 2025 17:35:55
 tools version      : 2.0.0
 complexity         : 8200 MACC
 c-nodes            : 4
 map_activations    : 1
  [0]  @0x20000000/1152
 map_weights        : 1
  [0]  @0x8010860/2896
 n_inputs/n_outputs : 1/1
  I[0] (1,8,8,2)128/i8 1:(0.003921,-128), @0x20000400/128
  O[0] (1,1,1,8)8/i8 1:(0.003906,-128), @0x200003E8/8

-------------------------------------------
| READY to receive a CMD from the HOST... |
-------------------------------------------

# Note: At this point, default ASCII-base terminal should be closed
# and a serial COM interface should be used
# (i.e. Python ai_runner module). Protocol version = 3.1
​
  • Now, I open from the IDE the .ico file, navigate to Pinout & Configuration -> Middleware and Software Packs -> X-CUBE-AI, and try to perform a validation. However, I get the error: LOAD ERROR: STM32 - read timeout 50007.9ms/50000ms

I tried to send random data (in the shape expected from the network) using python Serial and then reading them through picocom. In that case I can see unknow characters as the bytes are converted in ASCII. So, I suppose that the network gives some output...

Any suggestions on how to fix it?

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @Dresult ,

 

There is indeed a timeout error when using the .ioc from the dev cloud. It may be because of the memory  pool settings. I am still investigating this.

 

In the meantime, if you really need to do a validation on target, you just need to create a new CubeMX project, set everything by default, activate X Cube AI with the validation template. Generally, CubeMX ask if to set the optimal parameter after that, I generally click no. Then you import the model, click validate on target, check the option to flash the code and select STM32CubeIDE.

 

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.

View solution in original post

7 REPLIES 7
Julian E.
ST Employee

Hello @Dresult ,

Thank you for your message.

I have seen it one or two times, but I never got to have the user model to test it out.

I don't have a H7 with me today, I will test it out tomorrow.

 

I'll update you when I know more

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.
Dresult
Associate II

Hi Julian,

thanks a lot! Let me know if you need more information or if I can help in someway.

Looking forward to your update, have a good day too!

Hello @Dresult ,

 

There is indeed a timeout error when using the .ioc from the dev cloud. It may be because of the memory  pool settings. I am still investigating this.

 

In the meantime, if you really need to do a validation on target, you just need to create a new CubeMX project, set everything by default, activate X Cube AI with the validation template. Generally, CubeMX ask if to set the optimal parameter after that, I generally click no. Then you import the model, click validate on target, check the option to flash the code and select STM32CubeIDE.

 

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,

Thanks a lot for your time! I tried your solution, and now the validation works as expected. Please let me know if you find a solution for the .ioc file generated from the dev cloud :)

 

@Julian E. I have a question related to validation but not directly correlated to this issue...

I'm trying to deploy a model on the boards of the dev cloud, the initial layers are these:

Screenshot from 2025-03-27 11-59-16.png

however, when it comes to the quantization steps if I add an npz file for validation I receive this error:

[ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Invalid rank for input: input Got: 2 Expected: 3 Please fix either the inputs or the model.

the file in this case is generated with this code and resambles real inputs with a dimension for x of 1x4096x1 and y that is a 1x1.

import numpy as np

x_test = np.random.rand(1, 4096, 1).astype(np.float32)
y_test = np.random.rand(1, 1).astype(np.float32)

np.savez("test_data.npz", x_test=x_test, y_test=y_test)

It seems like if the validation tool internally performs a squeeze. Have you ever encountered this problem ?

Hello @Dresult ,

 

Can you send the model, I think that if you do a stedgeai generate, it is written somewhere, I would like to verify that.

Can you try to generate (batch_size,1,4096,1) and (batch_size,1,1)?

For example:

import numpy as np

x_test = np.random.rand(10,1, 4096, 1).astype(np.float32)
y_test = np.random.rand(10,1, 1).astype(np.float32)

np.savez("test_data.npz", x_test=x_test, y_test=y_test)

 

It is similar to this question: Solved: Error in Post-Training Quantization: 'Axis 2 is ou... - STMicroelectronics Community

 

I will need your model to know for sure.

Also the part about the idea that quantizing a small model can make it better may interest 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.

Thank you very much! With this input shape it works perfectly, however I don't understand, I thought the first dimension was the batch size...

I think, to test your data, the code do something like: prediction = model(X_test[i]).

So in your first code, X_test[0] would be of shape (4096,1) and not (1,4096,1).

 

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.