cancel
Showing results for 
Search instead for 
Did you mean: 

How to see an STM32 Prediction output after implementing a pre-trained model ?

OGaie
Associate III

How do you see an STM32 Prediction output after implementing a pre-trained model with MXCUBE and validating it on desktop and on target?

https://www.youtube.com/watch?v=grgNXdkmzzQ&t=

So i accomplished all the validation concerning the HAR CNN Keras Model , how can I see an obvious output of the prediction of the system ?

More explicitly: if i enter a custom data of a person "Walking" how can I see that the system has analyzed the data and predicted that the person is indeed walking...

10 REPLIES 10
Gln
ST Employee

Hi @OGaie​ ,

When using custom data as validation input, you can get a .csv log file of the output predicted values. The output file location is listed in the X-CUBE-AI log. For example:

Cross accuracy report (reference vs C-model) 
---------------------------------------------------------------------------------------------------- 
NOTE: the output of the reference model is used as ground truth value 
 
acc=100.00%, rmse=0.0003, mae=0.0001 
 
6 classes (12 samples) 
-------------------------------------- 
C0         2    .    .    .    .    .   
C1         .    2    .    .    .    .   
C2         .    .    2    .    .    .   
C3         .    .    .    2    .    .   
C4         .    .    .    .    2    .   
C5         .    .    .    .    .    2   
 
Creating C:\Users\legraing\.stm32cubemx\stm32ai_output\network_val_inputs.csv 
Creating C:\Users\legraing\.stm32cubemx\stm32ai_output\network_val_m_outputs.csv 
Creating C:\Users\legraing\.stm32cubemx\stm32ai_output\network_val_c_outputs.csv 
Creating C:\Users\legraing\.stm32cubemx\stm32ai_output\network_val_io.npz

In X-CUBE-AI v4.0.0, you can also provide some expected output (ground truth) to the tool and a confusion matrix will be shown in the output log.

Output files format is described in X-CUBE-AI v4.0.0, cli documentation, section 4.7 "Post-processing support (generated data files)"

C:/Users/<username>/STM32Cube/Repository/Packs/STMicroelectronics/X-CUBE-AI/4.0.0/Documentation/an_x_cube_ai_4.0_cli.html

Best regards,

Guillaume

OGaie
Associate III

I'm working on X-CUBE-AI v3.4 and using a pre-trained model based on the cifar10 dataset i have 10 classes here :

0 - airplane

1 - automobile

2 - bird

3 - cat

4 - deer

5 - dog

6 - frog

7 - horse

8 - ship

9 - truck

all I can see in the ai_outputs_model.csv and the ai_stm32_msg.log is this :

PS: i used a custom data for cat pictures

0690X000009YrolQAC.png

0690X000009Yrp0QAC.png

Gln
ST Employee

Hi @OGaie​ ,

Great! the ai_outputs_models.csv is the file you should be looking at.

In your spreadsheet, you can see you have 7 rows and 10 columns. Each row correspond to the output of an inference. I'm guessing that the last layer of your classifier model is a SoftMax activation function, in that case, you are getting the probability distribution of your 10 classes.

E.g., for the first row:

7.43e-07, 2.60e-28, ..., 9.99e-01, ..., 1.08e-20 -> index n#6 has the highest value (0.999). The first prediction output is a "6 - frog".

Best regards,

Guillaume

OGaie
Associate III

the data shape accepted in the custom data input in the MXCube for this model is 32*32*3

so I tired to enter the data of a "cat"

cat = {226,221,195,247,241,227,246,239,227,243,237,225,243,237,222,243,236,220,241,234,218,239,229,213,237,226,210,235,224,207,234,226,208,238,229,213,237,204,192,217,142,137,........,210,194,211,198,182}

and the prediction is always wrong ...

i tried to normalize the data in range of [-1,1] and its still wrong so i'm asking why?

and how can I enter a custom data easily in the shape demanded my mxcube model without going through python codes , arrays and conversions ...etc , just to create a custom data

Hi OGaie

I'm need an one dimensional artificial intelligence project with Stm32 so I am need to run this project.

I watched this video too but I don't know how to continue later. how did you manage to get an output like the one above?

I would be glad if you tell me step by step.

Regards

Using the MX Cube AI 4.0 you can see the confusion matrix in the validation on target , so first u need to configure your usart instance and run the cube ai package as validation and load it on your board , then u validate on target (in the mx cube ai interface provided ) using custom data to see if the model is working correctly

Thanks for your answer

How can I fix the error in this picture?0693W000000WHa5QAG.png

Check your cable if its connected or not and if you are using the usart configuration correctly?

you need to enable the usart from the interface too

I checked the cable, it is working properly.

Usart settings in the below. Do I need to make any other setting related to usart?0693W000000WHhfQAG.png0693W000000WHhVQAW.png