Thundercomm TurboX C8550/Intelligent SDK/TFLite SDK: Difference between revisions

From RidgeRun Developer Wiki
(Created page with "<noinclude> {{Thundercomm TurboX C8550/Head|previous=Intelligent SDK|next=Intelligent SDK/TFLite SDK|description=}} </noinclude> {{DISPLAYTITLE:Thundercomm TurboX C8550 - QIM SDK|noerror}} This section will help you to build, install and test the QIM SDK. The QIM (Qualcomm Intelligent Multimedia) SDK is a GStreamer-based SDK that provides a set of multimedia, CV (Computer Vision), and AI (Artificial Intelligence) plug-ins to facilitate application developers in develop...")
 
mNo edit summary
 
Line 1: Line 1:
<noinclude>
<noinclude>
{{Thundercomm TurboX C8550/Head|previous=Intelligent SDK|next=Intelligent SDK/TFLite SDK|description=}}
{{Thundercomm TurboX C8550/Head|previous=Intelligent SDK/QIM SDK|next=GStreamer_pipelines|metakeywords=thundercomm}}
</noinclude>
</noinclude>


{{DISPLAYTITLE:Thundercomm TurboX C8550 - QIM SDK|noerror}}
{{DISPLAYTITLE:Thundercomm TurboX C8550 - TFLite SDK|noerror}}


This section will help you to build, install and test the QIM SDK. The QIM (Qualcomm Intelligent Multimedia) SDK is a GStreamer-based SDK that provides a set of multimedia, CV (Computer Vision), and AI (Artificial Intelligence) plug-ins to facilitate application developers in developing suitable applications <ref name="intelligentsdk">TurboX C8550 Linux Embedded Standalone SDK Addon User Manual. Retrieved August 6, 2024, from [https://docs.thundercomm.com/turbox_doc/data/turbox-c8550/d_c8550_2/tc-p-23112-_turbox_c8550_linux_embedded_standalone-sdk-addon_user_manual_v1-2.pdf]</ref>. For this section it's required to have built the base SDK first. If not, please follow first the instructions on the [[Thundercomm TurboX C8550/Software_Support/SDK/Building_Images_from_Source|Building Images from Source]] section.
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. <ref name="intelligentsdk">TurboX C8550 Linux Embedded Standalone SDK Addon User Manual. Retrieved August 6, 2024, from [https://docs.thundercomm.com/turbox_doc/data/turbox-c8550/d_c8550_2/tc-p-23112-_turbox_c8550_linux_embedded_standalone-sdk-addon_user_manual_v1-2.pdf]</ref>. For this section it's required to have built the base SDK first. If not, please follow first the instructions on the [[Thundercomm TurboX C8550/Software_Support/SDK/Building_Images_from_Source|Building Images from Source]] section.


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


== Download the QIM SDK Code ==
== Download the TFLite SDK Code ==


1. Execute the SDK Manager container:
1. Execute the SDK Manager container:
Line 17: Line 17:
</pre>
</pre>


2. Download the QIM SDK code:
2. Download the TFLite SDK code:


<pre lang=bash>
<pre lang=bash>
Line 27: Line 27:
2.2. On the SDK branch selection, choose '''SDK.Turbox-QCS8550.LE.1.0.Standalone.sdk.addon'''.
2.2. On the SDK branch selection, choose '''SDK.Turbox-QCS8550.LE.1.0.Standalone.sdk.addon'''.


2.3. For version options, choose '''turbox-qim-sdk-1.0-dev.release.r000002'''.
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'''.
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-qim-sdk-1.0-dev.release.r000002''.
The code will be located at '' workspace/sourcecode/turbox-tflite-sdk-1.0-dev.release.r000002/''.


== Download the SNPE SDK Code ==
== Build the TFLite SDK ==
 
The QIM SDK workflow can generate the QIM SDK plugin for Qualcomm Neural Processing SDK (formerly known as SNPE). To build the SNPE QIM SDK plug-in, the SNPE SDK needs to be downloaded and the path to SNPE SDK needs to be provided in the configuration JSON file. The following steps will guide you through this process:
 
1. Go to the source code directory:
 
<pre lang=bash>
/home/turbox/workspace/sourcecode
</pre>
 
2. Get and unpack SNPE installation package:
 
<pre lang=bash>
wget https://thundercomm.s3.ap-northeast-1.amazonaws.com/uploads/web/c8550/snpe/SNPE-2.22.6.240515.zip
unzip SNPE-2.22.6.240515.zip -d snpe
</pre>
 
== Build the QIM SDK ==


1. Create the output directory for the SDK build:
1. Create the output directory for the SDK build:
Line 56: Line 39:
<pre lang=bash>
<pre lang=bash>
cd ~
cd ~
mkdir -p /home/turbox/workspace/intelligent-sdk/qim-sdk
mkdir -p workspace/intelligent-sdk/tflite-sdk
</pre>
</pre>


2. Go to the QIM SDK source code directory:
2. Go to the TFLite SDK source code directory:


<pre lang=bash>
<pre lang=bash>
cd workspace/sourcecode/turbox-qim-sdk-1.0-dev.release.r000002/sdk-tools
cd workspace/sourcecode/turbox-tflite-sdk-1.0-dev.release.r000002/tflite-tools
</pre>
</pre>


3. Build the QIM SDK:
3. Build the TFLite SDK:


<pre lang=bash>
<pre lang=bash>
source ./scripts/host/host_env_setup.sh
source ./scripts/host/host_env_setup.sh
qimsdk-setup targets/LE.PRODUCT.2.1.json
tflite-tools-setup targets/le-tflite-tools-builder.json
</pre>
</pre>


{{Colored box|background-title-color=#6586B9|title-color=#FFFFFF|title='''Note'''|icon=
{{Colored box|background-title-color=#6586B9|title-color=#FFFFFF|title='''Note'''|icon=
   |style=overflow:hidden;
   |style=overflow:hidden;
   |content=This step might take some time since it will run bitbake underneath, in our case it took around 1 hour the first time.
   |content=This step might take some time, in our case it took around 20 minutes.
  }}
  }}


4. Generate the QIM SDK artifacts:  
4. Generate the TFLite SDK artifacts:  


<pre lang=bash>
<pre lang=bash>
qimsdk-setup targets/LE.PRODUCT.2.1.json
source ./scripts/host/host_env_setup.sh
qimsdk-host-sync-artifacts-all targets/LE.PRODUCT.2.1.json
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
</pre>
</pre>


== Install the QIM SDK ==
== Install the TFLite SDK ==


1. Connect to the board via [[Thundercomm TurboX C8550/Development in the Board/Getting_into_the_Board/Using_adb|ADB]].
1. Connect to the board via [[Thundercomm TurboX C8550/Development in the Board/Getting_into_the_Board/Using_adb|ADB]].
Line 97: Line 82:
</pre>
</pre>


3. Push the QIM packages to the device:
3. Push the TFLite packages to the device:


<pre lang=bash>
<pre lang=bash>
cd /home/turbox/workspace/intelligent-sdk/qim-sdk  
adb push /home/turbox/workspace/intelligent-sdk/tflite-sdk/tflite-kalama-toolchain-/tflite-2.11.1-le/tflite_pkg/*.ipk /tmp  
unzip  packages_null.zip -d packages_null
adb push packages_null/*.ipk /tmp
</pre>
</pre>


4. Push the SNPE libraries to the device:
4. Install the packages inside the device:


<pre lang=bash>
<pre lang=bash>
adb shell "setenforce 0"
adb shell "opkg --force-depends --force-reinstall --force-overwrite install /tmp/*.ipk"
adb push /home/turbox/workspace/sourcecode/snpe/2.22.6.240515/lib/aarch64-oe-linux-gcc11.2/* /usr/lib/
adb push /home/turbox/workspace/sourcecode/snpe/2.22.6.240515/lib/hexagon-v73/unsigned/* /usr/lib/rfsa/adsp
adb push /home/turbox/workspace/sourcecode/snpe/2.22.6.240515/bin/aarch64-oe-linux-gcc11.2/* /usr/bin
</pre>
</pre>


5. Install the packages inside the device:
==Test the TFLite SDK==
 
1. Create the following directories for data:


<pre lang=bash>
<pre lang=bash>
adb shell "opkg --force-depends --force-reinstall --force-overwrite install /tmp/*.ipk"
mkdir -p ./data/Models
mkdir -p ./data/Labels
</pre>
 
2. Download the model file:
 
<pre lang=bash>
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
</pre>
 
3. Download the label file:
 
<pre lang=bash>
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/
</pre>
 
4. Push the files to the device:
 
<pre lang=bash>
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/
</pre>
 
5. Label the image in the device:
 
<pre lang=bash>
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"
</pre>
</pre>


==Test the QIM SDK==
You should get an output like this:


To test the QIM GStreamer elements please refer to the [[Thundercomm TurboX C8550/GStreamer pipelines|GStreamer Pipelines]] section.
<pre lang=text>
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
</pre>


== References ==
== References ==
Line 128: Line 149:


<noinclude>
<noinclude>
{{Thundercomm TurboX C8550/Foot|Intelligent SDK|Intelligent SDK/TFLite SDK}}
{{Thundercomm TurboX C8550/Foot|Intelligent SDK/QIM SDK|GStreamer_pipelines}}
</noinclude>
</noinclude>

Latest revision as of 18:48, 10 December 2024


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