Source code for converting TF model to TFLite Model

Hi,
I was wondering if there is any link or git repo where I can go through the module where I can see how does edge impulse converts tensorflow .pb model to tflite including processes that optimize the memory occupied.

Thanks.

Hi @umaid,

The code is not available but it’s based on the from_concrete_functions of the TFLiteConverter.

Aurelien

hi @aurel
how about deploying to the C++ library?is there a source code? or something that I can read?

Hi @devis,

The source code for building the C++ library in Edge Impulse is not open. However, it is built on top of TensorFlow Lite for Microcontrollers, which is open source. You can see what that process looks like here: TensorFlow Lite for Microcontrollers. The conversion tool from TFLite to TFLM takes a .tflite file and builds a C/C++ model in a flatbuffer. You then use the TFLM interpreter to run inference with that model in C++.

2 Likes

Hi, how do I integrate custom preprocessing like MFE on my audio into the tflite model or how do I generate a model to run on Arduino rather than python file?

Hi @umaid,

I don’t think there’s a way to integrate custom code into a .tflite model, as that is simply a collection of weights and operations to be read by the TensorFlow Lite interpreter (unless, of course, you could perform MFE as a series of TensorFlow operations…I don’t know if that’s possible).

In Edge Impulse, you can click on the Arduino library to generate a library for your DSP+ML blocks.

If you want to do this without the Edge Impulse code, it will take some effort. I go over the process to convert a TensorFlow Lite model file to a C++ FlatBuffer and load it onto an Arduino board in this 2-part series. Note that some of the steps might be out of date at this point, and I’m not sure what’s changed.

1 Like