Locating and replacing the Tflite model on Arduino library


I deployed a project I’ve been working on (keyword classifier via MFCC and CNN) to Arduino Nano 33 by using the Arduino library download option from the Deployment section.

I was wondering if I could replace the int8 tflite model trained from Edge Impulse with an int8 tflite model (same MFCC processing via speechpy and CNN architecture as the Edge Impulse model) that I trained in Jupyter Lab? And if so, where could I locate it in the Arduino library?


Hi @xerneaus,

This is actually very difficult to do, as Edge Impulse tightly couples the tflite model file with the downloaded C++ or Arduino library. It does not simply read in the tflite file, rather, it wraps it with Edge Impulse functions to make calling the DSP and inference sections easier.

If you’d like to see it, download the Arduino library impulse from your project, making sure to disable the EON compiler. Go to wherever Arduino keeps your libraries and <name-of-ei-project>/src/tflite-model/tflite-trained.h. You can see the converted TFLite model stored in there as a FlatBuffer.

Please see this guide for how to convert a TFLite file into a C array FlatBuffer. In theory, you should be able to copy that array into the tflite-trained.h file. However, this assumes that your inputs and outputs stay the same. I cannot say that this will work, as the Edge Impulse library expects the model to have certain operations and function in a certain way.

Is there a reason why you can’t create and train a new model inside of the Edge Impulse studio? I imagine that would be much easier.


Thanks for your answer Shawn.

It’s just that the model that I trained outside of Edge Impulse seems to generalize better so I’m assuming it has better performing weights than the one from EI. Also, I can utilize my GPU (I don’t know if EI supports GPU) which makes training faster.