mocleiri / tensorflow-micropython-examples

A custom micropython firmware integrating tensorflow lite for microcontrollers and ulab to implement the tensorflow micro examples.
MIT License
170 stars 79 forks source link

Support for Retrain the model on a device in MicroPython #119

Open alibukharai opened 1 year ago

alibukharai commented 1 year ago

Description: I am currently working on a project using ESP32 and ESP32-S3 boards and utilizing the microlite library for running TFLite models in MicroPython. First of all, I would like to express my gratitude for this excellent library and its support for TFLite in MicroPython.

I am exploring ways to push the capabilities of the ESP32 board to its limits. As part of my project, I would like to investigate the possibility of training and retraining TFLite models in real-time using the microlite library.

Specifically, I am interested in the following capabilities:

Training TFLite models: Is it possible to utilize the microlite library to train TFLite models directly on the ESP32 board? This would involve updating the model weights and biases during runtime based on real-time data. It would be beneficial for scenarios where the model needs to adapt and improve its performance continuously.

I would appreciate any insights, guidance, or examples on how to achieve these capabilities using the microlite library. Additionally, if these features are not currently supported, I would be interested to know if there are any plans or possibilities of adding such functionality in future updates.

Thank you for your attention and support. I look forward to any feedback or suggestions regarding training and real-time retraining of TFLite models using the microlite library in MicroPython.

Here are some useful relevant resources

  1. Tensorflow
  2. Article 1
  3. Article 2
mocleiri commented 1 year ago

The model file is stored on the filesystem so can be edited. Its a Flatbuffer file: https://flatbuffers.dev/ Reference: https://www.tensorflow.org/lite/microcontrollers/build_convert#model_conversion

At the moment the model doesn't map to any Micropython type its just a byte array.

If you can find the c or c++ methods needed to enable rewriting the model weights something could be surfaced into the microlite api to allow calling from micropython.