2022-09-17 10:32 PM
I'm trying to Implement basic MNIST Handwritten Digit recognition Model on STM32F769 DISC1 kit using STM Cube AI.
Here are the steps I followed.
It is provided by google colab.
2. downloaded the .h5 file
3 Created the project using STM32CUBE MX, in that included the STM32 CUBE AI Software pack. Included the core and selected application as 'application template'
4 Using keeping other initializations default and selecting clock frequency 216 MHz, I generated the code.
5 kept main program untouched (where MX_X_CUBE_AI_Process(); is called in while(1) loop.
6 in app_x-cube-ai.c file made the modifications as told in 'Embedded Interface Client API' in documentation.
Here I have no device to actually record the handwritten digit, therefore I copied one of the training dataset sample manually from ipython notebook and saved it in array in app_x-cube-ai.c file. Note that my training was done for the values originally 0 to 255 normalized to 0 to 1.
as stated ,I saved the pixel values for one of the digit in an array called 'imgarray' which is equal to the size 28 x 28. the datatype of 'imgarray' i kept as ai_double.
7 on running the inference in debug mode, I found the output (which were stored in an array out_data[10].) unsatisfactory.
8 moreover, the most concerning this is that even if i changed the value of 'imgarray' with pixel values of different digit, the output result in the 'out_data' array REMAINS EXACTLY THE SAME
Is there anything that I'm doing wrong fundamentally.
Request my fellow developers on STCommunity to guide me.
2022-09-18 11:28 PM
Did you use proper input tensor format ? Please see following excerpt of mentioned google colab description:
"In order to use convolution layers we need to reshape our data and add a color channel to it. As you've noticed currently every digit has a shape of `(28, 28)` which means that it is a 28x28 matrix of color values form `0` to `255`. We need to reshape it to `(28, 28, 1)` shape so that each pixel potentially may have multiple channels (like Red, Green and Blue)."
Another, quite common problem is the order of the tensor shape size when feeding the NN.
Best regards,
Bartosz