Make sure to have Python 3.10 installed. At the time TinyMaix, used for CNN, only supports Tensorflow <2.14, which is not supported on Python 3.12 or later.
Make sure to have the Unix port of MicroPython 1.23 setup. On Windows you can use Windows Subsystem for Linux (WSL), or Docker.
Install the dependencies of this example:
python -m venv venv
source venv/bin/activate
pip install -r requirements.txtThis will train a Convolutional Neural Network using Keras.
The process will output .tmdl that is our built model.
python mnist_train.pymicropython -m mip install https://emlearn.github.io/emlearn-micropython/builds/master/x64_6.3/emlearn_cnn.mpy
micropython mnist_cnn_run.py!Make sure you have it running successfully on host first.
Flash your device with a standard MicroPython firmware, from the MicroPython.org downloads page.
mpremote mip install https://emlearn.github.io/emlearn-micropython/builds/master/xtensawin_6.3/emlearn_cnn.mpympremote cp mnist_cnn.tmdl :
mpremote cp -r data/ :
mpremote run mnist_cnn_run.pyThis example requires hardware with an ESP32 chip, and an OV2640 camera module. It has been tested on Lilygo T-Camera Mic v1.6.
You need to build a custom ESP32 firmware, and add this C module for camera access: https://github.com/cnadler86/micropython-camera-API
mpremote run mnist_cnn_camera.py