tinymlgen
tinymlgen copied to clipboard
Generate C code for microcontrollers from Tensorflow models
TinyML gen
This is a simple package to export a model trained in Tensorflow Lite to a plain C array, ready to be used for inference on microcontrollers.
Install
pip install tinymlgen
Use
from tinymlgen import port
if __name__ == '__main__':
tf_model = create_tf_model()
c_code = port(tf_model)
Configuration
You can pass a few parameters to the port function:
optimize (=True): apply optimizers to the exported model. Can either be a list of optimizers or a boolean, in which caseOPTIMIZE_FOR_SIZEis appliedvariable_name (='model_data'): give the exported array a custom namepretty_print (=False): print the array in a nicely formatted arrangement