tensorflowlite in SDK CLI
-
In SDK CLI environment, there is TFLM example given on the website
Reference:
https://developer.sony.com/develop/spresense/docs/sdk_tutorials_en.html#_tensorflow_tutorials
Since SDK CLI supports only the C language but TFLM is in python,
how to run this TF model and convert it into a C byte array model in SDK CLI environment -
Hi @Chandasri-G,
The following steps are required to deploy and run a TensorFlow model on a Spresense:
1. Train a model:
-
Generate a small TensorFlow model that can fit your target device and contains supported operations: https://www.tensorflow.org/lite/microcontrollers/build_convert#operation_support.
-
Convert to a TensorFlow Lite model using the TensorFlow Lite converter: https://www.tensorflow.org/lite/microcontrollers/build_convert#model_conversion.
-
Convert to a C byte array using standard tools to store it in a read-only program memory on device: https://www.tensorflow.org/lite/microcontrollers/build_convert#convert_to_a_c_array
2. Run inference on device using the C++ library and process the results.
So first you train your model on your PC. You can use Python for that. However, to run the model on Spresense you must use the TensorFlow Lite Micro library. It is written in C++. To make it easier to use this library on the Spresense SDK we have created a wrapper for this library. It's called TFLM Runtime: https://developer.sony.com/develop/spresense/docs/sdk_developer_guide_en.html#_tflm_runtime
I hope it helps you.
Best Regards,
Kamil Tomaszewski -