Skip to main content
NAghl
Associate
May 1, 2019
Question

MNIST and Quick Draw on STM32F429ZI

  • May 1, 2019
  • 3 replies
  • 1953 views

Hello Everybody,

I just wanted to share with you two projects I have done with CUBEMX.AI.

ALL networks are trained with TensorFlow 2.0.

Tensoflow2.0 saved networks(Keras Format) receives an error when converting in CUBEMX so I changed some options in python code to make it compatible with CUBEMX.AI.

Links to github:

https://github.com/nimaaghli/STM32AI_MNIST

https://github.com/nimaaghli/STM32AI_QuickDraw

Link to video demonstrations:

https://www.youtube.com/watch?v=8oBEGNwsj4A

https://www.youtube.com/watch?v=_YbzxUagpbw

This topic has been closed for replies.

3 replies

hirotakaster
Associate
January 6, 2020

I have a same problem. I think maybe CubeMX/Artificial Inteligence is not compatible to Tensorflow 2.0 yet.

Windows 10

CubeMX 5.4

Artificial Inteligence 5.0.0

TensorFlow 2.0(Keras) model is here(very simple).

_________________________________________________________________

Layer (type) Output Shape Param #

=================================================================

dense_66 (Dense) (None, 40) 680

_________________________________________________________________

dense_67 (Dense) (None, 20) 820

_________________________________________________________________

dense_68 (Dense) (None, 3) 63

=================================================================

Total params: 1,563

Trainable params: 1,563

Non-trainable params: 0

_________________________________________________________________

But I got a INVALID MODEL error when I try "Analyze" on CubeMX.

0690X00000BvbeLQAR.png

NAghl
NAghlAuthor
Associate
January 6, 2020

Hi,

Please add following to each layer. It would fix the problem.

kernel_initializer='random_uniform'

for example :

model.add(tf.keras.layers.Dense(256, activation='relu',kernel_initializer='random_uniform'))

hirotakaster
Associate
January 6, 2020

Hi,

Analyze works!! thank you.

Fernando1
Associate II
January 7, 2020

Hi, I asked a question about how to make predictions. I will see your code to see if I can answer. I want to send the 28x28 image by uart, since I am using a generic plate with an STM32F4VE. Thanks!

Fernando1
Associate II
January 7, 2020

Hello again. I was seeing the code generated by STM32Cube.AI and generated a code for verification. Is it possible to generate code for prediction? Looking at your code, I see that it is different from the one generated by STM32Cube.AI, could you explain how to generate it? And if you did it manually, could you explain it to me? Greetings.

NAghl
NAghlAuthor
Associate
February 6, 2020

Hi,

I have actually used STM32Cube.AI to generate the files. I do prediction inside app_x-cube-ai.c (generated by CubeAI) using MX_X_CUBE_AI_Process() method. That is where I pass the image information in float values(Pixel values are normizled from 0-255 to 0-1)