<--

Stm32f429 Tflite Micro Mnist Handwritten Number Recognition

In September 2020, I was looking for a way to better understand machine learning. As I embedded software engineer, I was loooking for something related with this field and I found that tensorflow had added support for microcontrollers which is called TensorFlow Lite for Microcontrollers. I enrrolled a course in edx called Fundamentals of TinyML. Right now, there is a serie which also includes Application of TinyML and Deploying TinyML which we were not available at the moment that I enrolled the course.

When I finish the course, I had the idea of doing some project in which I deploy something in real hardware. I have a STM32F429I-DISCO in which I thought about running some application in this board. There were many ideas but I choose handwritten number recognition using The mnist database. I spent some weeks figuring out how to do so, there were not many examples, just Hello World example which predict value of sinwave using TFLM interpreter and few platform support. For real, the main tf project includes this as subfolder, right now, there is a different repository for this.

I was able to finish this project and push the code to my github account with the name of stm32f429-tflite-micro-mnist. I did not spent to much time in improvement, I faced some problems related with the use of the model. I just put the effort in making everything to work. The model needs almost 2 seconds for running the model.

handwritten_2020

This week, I was reading an article about an optimized kernel implementations in Cortex-M and I read CMSIS-NN. At the moment that I publish this toy project there was not specific kernel for Cortex-M in TFLM, I have tried this optimized kernel and the same model runs almost ten times faster.

comparation_image

handwritten_2024

CMSIS-NN is a collection of efficient neural network kernels developed to maximize the performance and minize the memory footprint of neural networks on Cortex-M processor.