Sony's Developer World forum

    • Home
    • Forum guidelines

    tensorflowlite in SDK CLI

    Spresense
    2
    2
    240
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      Chandasri G last edited by Chandasri G

      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

      K 1 Reply Last reply Reply Quote
      • K
        KamilTomaszewski DeveloperWorld @Chandasri G last edited by

        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

        1 Reply Last reply Reply Quote
        • First post
          Last post
        Developer World
        Copyright © 2021 Sony Group Corporation. All rights reserved.
        • Contact us
        • Legal