Tflite-micro with platformio latest tutorial

I am relatively new to embedded systems, trying to profile my tensorflow models in esp 32 chips. I followed this tutorial (GitHub - atomic14/tensorflow-lite-esp32: SImple example getting TensorFlow Lite up and running on the ESP32 with Platform.io) and it has been really helpful for a few models and to get started.

Now that tflite-micro is a bit outdated (2019) and some ops that I wanted are missing but is present in the tflite-micro(2021). Are there any similar recent tutorial ?

https://github.com/tensorflow/tflite-micro-arduino-examples is more official, but its tflite core is also 1 year old by now. But for sure newer than the 3 year old one from the example you linked.

Otherwise be those listed in PlatformIO Registry, e.g.

With 3 simple code changes (making destructors of 2 classes public, adding the ringbuffer class from ArduinoCore/api), this example can be brought to compilation and work.

https://github.com/maxgerhardt/pio-esp32-tflitemicro-example

Still, you’ll probably want to use https://github.com/espressif/esp-nn for best performance and integration with Espressif chips.

1 Like

Hi Max , Thank you !

This is exactly what I wanted.

There is still a issue in implementing a neural network. The last time, there was no ops like LeakyRelu, Transpose so I was trying to fit them in and failed now in your latest repo I see them all in the kernels but I don’t know how to call them. in the (tensorflow-lite-esp32/firmware/src/NeuralNetwork.cpp at master · atomic14/tensorflow-lite-esp32 · GitHub) because the way to initialize the interpreter has changed.

The author of that repo also has a note that he will update his repo for latest cores and what you have is exactly that on, thanks again !

Nice. You might want to keep an eye on https://github.com/espressif/esp-tflite-micro/issues/87, I did try to go with the optimum Espressif-optimized and recent TFLite library version, but with PlatformIO, that’s not working correctly during runtime… It would probably work when using native ESP-IDF directly, without PlatformIO. Not using the custom Espressif optimization will lead to worse performance results than is actually possible with the chip, so don’t feel bad about disabling the PlatformIO extension for this and using ESP-IDF instead.

Thanks, Max. Your inputs were very helpful. Much appreciated!