Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time

This repo is now way out of date - I'll try and do an update soon.

You should now go here:

Extract tensorflow-lite for use in with the ESP32

A word of warning on this code - if you use the master release of TensorflowLite you will probably hit compilation errors as the code moves quite quickly and the Arduino framework does not. If you hit compilation errors, then it's worth trying a particular version of TensorflowLite and the ESP IDF.


docker build . -t tflite-generator --build-arg tensorflow_version=2.4.0 --build-arg esp_idf_version=release/v4.3

There are a few blog posts on how to pull out tensorflow-lite for use with

I've tried to minimise the amount of restructuring of the tfmicro folders in this repo by making using a library.json to setup include paths.

This should make it easier to update to newer versions of TensorflowLite as they become available.

To build the docker file run

docker build . -t tflite-generator

You can specify arguments for this - for example to use the master branch of TensorFlow do the following:

docker build . -t tflite-generator --build-arg tensorflow_version=master

And to specify the esp-idf version:

docker build . -t tflite-generator --build-arg tensorflow_version=master --build-arg esp_idf_version=release/v4.3

This can take a considerable amount of time as the stage where it downloads can take a while. Got off and make a cup of tea.

Once the docker image has been built you can copy the code out of the image using:

docker run -v $PWD/lib:/dst -t tflite-generator

This will copy the tfmicro source code for the ESP32 into a folder called lib.

Copy the contents of the lib folder into your project's lib folder.

Copy the library.json into the tfmicro folder in your lib folder.

Edit the file lib/tfmicro/third_party/flatbuffers/include/flatbuffers/base.h

And change lines 34 onwards to look like this:

// #if defined(ARDUINO) && !defined(ARDUINOSTL_M_H)
//   #include <utility.h>
// #else
  #include <utility>
// #endif

For release 2.3 of TensorFlow you will need to edit the file lib/tfmicro/tensorflow/lite/micro/ and find the line that refers to static_assert add a message to the end of this to remove the compilation error or just comment out the block.

      static_assert((std::is_same<kFlatBufferVectorType, int32_t>() &&
                     std::is_same<kTfLiteArrayType, TfLiteIntArray>()) ||
                    (std::is_same<kFlatBufferVectorType, float>() &&
                     std::is_same<kTfLiteArrayType, TfLiteFloatArray>()), "Error");

If you are using the master branch of TensorFlow then this is not needed as the code has changed substantially.

You may also get compilation errors around std::fmax and std::fmin.

You will need to modify the files to use std::max and std::min.

That should do it!


Easily extract the tfmicro framework for use in







No releases published


No packages published