Thundercomm TurboX C8550 - TFLite SDK

From RidgeRun Developer Wiki


Index






This section will help you to build, install and test the TFLite SDK. TFLite (TensorFlow) SDK is a library for deploying models on mobile devices, microcontrollers and other edge devices. [1]. For this section it's required to have built the base SDK first. If not, please follow first the instructions on the Building Images from Source section.

Please follow the next steps in order to configure it properly.

Download the TFLite SDK Code

1. Execute the SDK Manager container:

turbox-sdkmanager-setup.sh --os-version 18.04 -u

2. Download the TFLite SDK code:

sdkmanager --sdk_download

2.1. When asked for the product to use, select Turbox_C8550.

2.2. On the SDK branch selection, choose SDK.Turbox-QCS8550.LE.1.0.Standalone.sdk.addon.

2.3. For version options, choose turbox-tflite-sdk-1.0-dev.release.r000002.

2.4. Press Enter to download the SDK code in the default path, and the confirm typing Yes.

The code will be located at workspace/sourcecode/turbox-tflite-sdk-1.0-dev.release.r000002/.

Build the TFLite SDK

1. Create the output directory for the SDK build:

cd ~
mkdir -p workspace/intelligent-sdk/tflite-sdk

2. Go to the TFLite SDK source code directory:

cd workspace/sourcecode/turbox-tflite-sdk-1.0-dev.release.r000002/tflite-tools

3. Build the TFLite SDK:

source ./scripts/host/host_env_setup.sh
tflite-tools-setup targets/le-tflite-tools-builder.json
Note
This step might take some time, in our case it took around 20 minutes.

4. Generate the TFLite SDK artifacts:

source ./scripts/host/host_env_setup.sh
tflite-tools-host-get-rel-package targets/le-tflite-tools-builder.json
tflite-tools-host-get-dev-package targets/le-tflite-tools-builder.json
tflite-tools-host-get-dev-tar-package targets/le-tflite-tools-builder.json

Install the TFLite SDK

1. Connect to the board via ADB.

2. Remount the filesystem:

adb root 
adb remount 
adb shell mount -o remount,rw / 
adb shell "mkdir -p /tmp"

3. Push the TFLite packages to the device:

adb push /home/turbox/workspace/intelligent-sdk/tflite-sdk/tflite-kalama-toolchain-/tflite-2.11.1-le/tflite_pkg/*.ipk /tmp 

4. Install the packages inside the device:

adb shell "opkg --force-depends --force-reinstall --force-overwrite install /tmp/*.ipk"

Test the TFLite SDK

1. Create the following directories for data:

mkdir -p ./data/Models 
mkdir -p ./data/Labels 

2. Download the model file:

curl https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_2018_02_22/mobilenet_v1_1.0_224.tgz | tar xzv -C ./data 
mv ./data/mobilenet_v1_1.0_224.tflite ./data/Models

3. Download the label file:

curl https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_1.0_224_frozen.tgz | tar xzv -C ./data  
mv ./data/mobilenet_v1_1.0_224/labels.txt ./data/Labels/

4. Push the files to the device:

adb root 
adb remount 
adb shell mount -o remount,rw / 
adb push ./data/Labels /data 
adb push ./data/Models /data 
adb push /home/turbox/workspace/intelligent-sdk/tflite-sdk/tflite-kalama-toolchain-/tflite-2.11.1-le/src/tensorflow/lite/examples/label_image/testdata/grace_hopper.bmp /data/Labels/

5. Label the image in the device:

adb root 
adb shell "label_image -l /data/Labels/labels.txt -i /data/Labels/grace_hopper.bmp -m /data/Models/mobilenet_v1_1.0_224.tflite -c 10 -j 1 -p 1"

You should get an output like this:

INFO: 0.860174: 653 653:military uniform
INFO: 0.0481019: 907 907:Windsor tie
INFO: 0.007867: 466 466:bulletproof vest
INFO: 0.00644933: 514 514:cornet, horn, trumpet, trump
INFO: 0.00608029: 543 543:drumstick

References

  1. TurboX C8550 Linux Embedded Standalone SDK Addon User Manual. Retrieved August 6, 2024, from [1]


Index