Level up your TinyML skills

TinyMLgen for Python

A Python package to export TensorFlow Lite neural networks to C++ for microcontrollers

TinyMLgen for Python

Tinymlgen is a Python library to export TensorFlow models into C format with a single line of code.

As an Arduino maker, you can then run that model on your microcontroller using the EloquentTinyML library.

Installation

Tinymlgen is available on PyPi, so you can use pip to install.

pip install -U tinymlgen

Or you can clone the Github repo

git clone https://github.com/eloquentarduino/tinymlgen
PCBWay

How to use

Tinymlgen package has a single method called port(): it accepts a TensorFlow model and returns the C code you need to import in your Arduino sketch.


from tinymlgen import port

if __name__ == '__main__':
    tf_model = create_tf_model()
    c_code = port(tf_model)

    with open('tensorflow_model.h', 'w') as file:
        file.write(c_code)
        

Want to quickly integrate TensorFlow Lite models into your Arduino project? EloquentTinyML library makes it a breeze.

Configuration

The port() method accepts 2 optional configuration options:

  • variable_name (str, defaults to 'model_data'): this is the name of the exported variable in C
  • pretty_print (bool, defaults to False): if True, the output is formatted in a more readable format

Having troubles? Ask a question

Related posts

libraries

MicroMLGen for Python

A Python library to export scikit-learn models into C format with a single line of code

tinyml

Arduino WiFi Indoor Positioning

Localize people and objects as they move around your building with the power of Machine Learning

esp32-cam

Esp32 Camera Object Detection

The beginner-friendly guide to run Edge Impulse FOMO Object Detection on the Esp32 Camera with little effort

tinyml

TensorFlow Lite on Esp32

Convert an existing TensorFlow Lite model to be deployed on your ESP32 board using the Arduino IDE

libraries

EloquentTinyML for Arduino

An Arduino library to make TensorFlow Lite for Microcontrollers neural networks more accessible and easy to use

Get monthly updates

Do not miss the next posts on TinyML and Esp32 camera. No spam, I promise

We use Mailchimp as our marketing platform. By submitting this form, you acknowledge that the information you provided will be transferred to Mailchimp for processing in accordance with their terms of use. We will use your email to send you updates relevant to this website.

Having troubles? Ask a question

© Copyright 2023 Eloquent Arduino. All Rights Reserved.