Can platform.io run tensorflowjs-converter a python and linux command line package?

Can platform.io run tensorflowjs-converter a python and linux command line package?

@maxgerhardt @ivankravets

Small machine learning models can easily be made using browser Javascript and tensorflowJS. I am an expert at that.

Microprocessors can load TFLITE models for machine learning analysis using Platform.io and lots of other methods like edgeimpulse.com. I am also an expert at that but it is so easy anyone could do it.

But typically we have to load a python module called tensorflowjs-converter to convert a tensorflowJS model into a keras model and then into a TFLITE model.

Can all of this be done with platform.io? Can it run a python or linux command once the converter is installed?

The actual commands are almost exactly the same each time.

The install commands are:

pip install tf-nightly 
pip install tensorflowjs
pip install netron

also check that xxd has been installed with

xxd -h
``


Convert tensorflowjs to keras, then to TFLITE then to a c header file with xxd. Then view it with netron.

tensorflowjs_converter --input_format=tfjs_layers_model --output_format=keras_saved_model ./model.json ./

tflite_convert --keras_model_file ./ --output_file ./model.tflite

xxd -i model.tflite model.h

netron model.tflite

You can post-install arbitrary python package in PlatformIO’s virtualenv environment as long as they don’t have conflicting dependencies with something else (in which case, you would need to create a new virtual environement, which is something that the ESP-IDF builder script does).

Thus, duplicate of How to use own python libraries in extra_script.py - #2 by maxgerhardt.

1 Like