GithubHelp home page GithubHelp logo

szu-chi / implement-mnist-handwritten-digit-classification-on-mcu Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 1.77 MB

This repository demonstrate how to implement CNN on MCU by using STM32 Cube-AI.

License: MIT License

C 99.57% Assembly 0.34% Python 0.09%
mnist stm32 cube-ai

implement-mnist-handwritten-digit-classification-on-mcu's Introduction

Implement MNIST Handwritten Digit Classification on MCU

This repository demonstrate how to implement CNN on MCU by using STM32 X-Cube-AI.

Environment
OS Win11
MCU NUCLEO-F411RE
Python 3.9.12
Keras 2.6.0
Tensorflow 2.8.0
X-Cube-AI 7.2.0
IDE VScode, STM32CubeIDE

Workflow:

  1. Using Keras build classification model.
  2. Create STM32 project.
  3. Testing classification performance on MCU

Using Keras build classification model.

python3 train_model.py

image

Model Summary

Layer (type) Output Shape Param #
input_1 (InputLayer) [(None, 28, 28, 1)] 0
conv2d (Conv2D) (None, 8, 8, 8) 208
conv2d_1 (Conv2D) (None, 3, 3, 16) 1168
flatten (Flatten) (None, 144) 0
dense (Dense) (None, 10) 1450

Total params: 2,826
Trainable params: 2,826
Non-trainable params: 0

Create STM32 project.

Step 1 Create New STM32 project:

  1. Select NUCLEO-F411RE
    image
  2. Create STM32 Project
    image

Step 2 Setup STM32 Peripherals:

1. X-Cube-AI

  • Click Software Packs -> Select Components
    image
  • Enable X-CUBE-AI Core
    image
  • Add Network
    • Software Packs -> STMicroelectronics.X-CUBE-AI.7.2.0 -> Add network
    • Change model name to digit_cnn
    • Click Browse button select pre-trained model digit_classifier_CNN.h5
    • Software Packs -> STMicroelectronics.X-CUBE-AI.7.2.0 -> Analyze image
  • Software Packs -> STMicroelectronics.X-CUBE-AI.7.2.0 -> Show graph\
    image

2. Activate TIM11

image

3. Enable Virtual Com Port Global Interrupt

image

4. Enable generate peripheral initalization as a pair of '.c/.h' file per peripheral

image

5. Generate code and Replace Scirpt

  • Core/Inc/main.h
  • Core/Src/main.c
  • Core/Src/stm32f4xx_it.c

6. Upload program to STM32

Testing classification performance on MCU

This repository testing architecture shown as below figure. image

python3 testing_on_mcu.py

Demo Video Link:

  • [Using Keras build classification model]
  • [Create STM32 project]
  • [Testing classification performance on MCU]

Reference:

implement-mnist-handwritten-digit-classification-on-mcu's People

Contributors

szu-chi avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.