Skip to main content
Associate
March 1, 2025
Solved

How to pass data to my model?

  • March 1, 2025
  • 3 replies
  • 628 views

HI! 

I am newbie to CUBE AI. 

I m working on implementing my CNN network that takes input image of 128,128,1 (greyscale) and give an output of 3 classes {class1,class2,class3}.

i did convert and try my model to TFLITE successfully on python.

 then i went to stmcube and did put the model using X-CUBE-AI application template .

my problem is with 

 

 

 

int acquire_and_process_data(ai_i8* data[])
{
 /* fill the inputs of the c-model
 for (int idx=0; idx < AI_NETWORK_IN_NUM; idx++ )
 {
 data[idx] = ....
 }

 */
 return 0;
}

 

 

my input buffer is like this

 

 

#define AI_NETWORK_IN_1_FORMAT (AI_BUFFER_FORMAT_FLOAT)
#define AI_NETWORK_IN_1_HEIGHT (128)
#define AI_NETWORK_IN_1_WIDTH (128)
#define AI_NETWORK_IN_1_CHANNEL (1)
#define AI_NETWORK_IN_1_SIZE (16384)
#define AI_NETWORK_IN_1_SIZE_BYTES (65536)

 

 

i tried putting image as image [128*128] and image[128][128]

Best answer by Julian E.

Hello @YahiaHedna ,

 

you are using float input, please try to change the 

int acquire_and_process_data(ai_i8* data[])

to 

int acquire_and_process_data(ai_float* data[])

then pass a float array of size 128x128=16384 to data[idx] 

 

Have a good day,

Julian

3 replies

Julian E.
Julian E.Best answer
Technical Moderator
March 3, 2025

Hello @YahiaHedna ,

 

you are using float input, please try to change the 

int acquire_and_process_data(ai_i8* data[])

to 

int acquire_and_process_data(ai_float* data[])

then pass a float array of size 128x128=16384 to data[idx] 

 

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

Thank you Julian!  

I figured out the problem and I was getting that error because of the improper data passing to the input layer.

Thanks again for your time!

Associate III
June 25, 2025

1. My image data is transmitted through a serial port or USB. How can I convert this image data into the data that needs to be received by int acquire_ and_decess_data (ai_i8 * data [])?
2. Do I need to convert these image data into BMP format first, and then put it into ai_i8 * data []? However, this parameter does not provide array length data, nor do I have input parameters for length and width dimensions. How can I convert an image data into ai_i8 * data [] format?

Associate
June 26, 2025

Use netron to check the input type of your model, if its float, uint .....

Then, do change data from ai_i8 to your input type.

Finnally, if your input is 64x64, ur data should have 4096 values, that you pass to your ai_run