# Get started
Source: [https://docs.qualcomm.com/doc/80-70015-54/topic/getting-started.html](https://docs.qualcomm.com/doc/80-70015-54/topic/getting-started.html)
This information explains how to run TensorFlow Lite models on the Qualcomm Linux
Development Kit.
Before you get started, do the following:
- Set up the Qualcomm Linux Development Kit. For instructions, see the following:
- QCS6490/QCS5430: [RB3 Gen 2 Quick Start Guide](bundle/publicresource/topics/80-70015-253)
- QCS9075: [Qualcomm^®^ IQ-9100 Beta
Evaluation Kit Quick Start Guide](https://docs.qualcomm.com/bundle/80-70015-263/resource/80-70015-263_REV_AB_Qualcomm_IQ-9100_Beta_Evaluation_Kit_Quick_Start_Guide.pdf)
Note: This
guide is currently available for Authorized users only. To upgrade your
access, go to [www.qualcomm.com/support/working-with-qualcomm](https://www.qualcomm.com/support/working-with-qualcomm).
- Connect the Qualcomm Linux Development Kit to a monitor using HDMI.
- Upgrade the Qualcomm Linux Development Kit with the latest software release
available on [CodeLinaro Artifactory Service](https://artifacts.codelinaro.org/ui/native/qli-ci/flashable-binaries/).
- Flash the image to the device. For instructions, see [Flash images](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-254/flash_images.html).
## Run a TensorFlow Lite model using the Gstreamer-based IM SDK
Source: [https://docs.qualcomm.com/doc/80-70015-54/topic/getting-started.html](https://docs.qualcomm.com/doc/80-70015-54/topic/getting-started.html)
The Qualcomm Linux Development Kit ships with precompiled TensorFlow Lite sample
applications to run sample TensorFlow Lite models.
The gst-ai-classification sample application uses the IM SDK plug-ins to run a TensorFlow
Lite classification model on the Qualcomm Linux Development Kit with hardware
acceleration using TensorFlow Lite delegates.
Figure : Workflow to run a TensorFlow Lite model using IM SDK
The gst-ai-classification sample application does the following:
1. Opens the IMX577 camera present on the Qualcomm Linux Development Kit with a
specific resolution and fps; for example, 1080p at 30 fps.
2. Preprocesses each camera frame to provide the input data to a classification
model.
For example, the gst-ai-classification sample application:
1. Downscales a 1080p frame to a 224 x 224 resolution
2. Normalizes the input frame based on the model requirements
3. The qtimltflite IM SDK plug-in, which is written on top of the TensorFlow Lite C++
API, does the following:
1. Loads the sample TensorFlow Lite classification model
2. Performs inference on the model provided with hardware acceleration
4. Postprocesses the output from the inference, that is, extracts the label with
highest predicted probability within the output tensor.
5. Overlays the inference result on the original camera input image and displays it on
the connected monitor.
### Download and copy a sample model
To download and copy a model and a label file to the device, do the following:
1. Go to [Qualcomm^®^ AI Hub](https://aihub.qualcomm.com/iot/models/inception_v3_quantized?searchTerm=inception) and
download the Inception-v3-Quantized model. 
2. To download the label file corresponding to this model, run the following
command:
wget https://github.com/quic/ai-hub-models/blob/main/qai_hub_models/labels/imagenet_labels.txtCopy to clipboard
Note: Models are hosted on Qualcomm AI Hub and model labels
are hosted on the Qualcomm AI Hub GitHub repository.
3. To copy the models and label files to the device using the secure copy protocol
(SCP), run the following
commands:
# For SCP, run the following command:
ssh root@[ip-addr]
mount -o remount,rw /
exitCopy to clipboard
# Copy files securely
scp imagenet_labels.txt root@[ip-addr]:/opt/
scp inception_v3_quantized.tflite root@[ip-addr]:/opt/
Copy to clipboard
Note: When prompted for a password, enter
oelinux123.
### Execute a TensorFlow Lite model with a sample application
1. To run inference using TensorFlow Lite Runtime, run the following
commands:
ssh root@[ip-addr]Copy to clipboard
# Setup Wayland Display environment
export XDG_RUNTIME_DIR=/dev/socket/weston && export WAYLAND_DISPLAY=wayland-1Copy to clipboard
# Run a classification sample app
gst-ai-classification --ml-framework=2 --model=/opt/inception_v3_quantized.tflite --labels=/opt/imagenet_labels.txt -k "Inception,q-offsets=<33.0>,q-scales=<0.18740029633045197>;"Copy to clipboard
2. To run the sample application using a custom classification model, use the
following arguments:
- `--model`
- `--labels`
For
example:
gst-ai-classification --ml-framework=2 --model=/opt/custom_model.tflite --labels=/opt/custom_label.txtCopy to clipboard
3. To stop the sample application, press CTRL+C.
When the sample application is running, it displays the camera stream on the
connected monitor with inference results overlaid on the frame.
## Run a TensorFlow Lite model using a native TensorFlow Lite sample application
Source: [https://docs.qualcomm.com/doc/80-70015-54/topic/getting-started.html](https://docs.qualcomm.com/doc/80-70015-54/topic/getting-started.html)
You can run TensorFlow Lite models using a sample TensorFlow Lite application called
label\_image, which is a part of the TensorFlow repository.
The label\_image sample application and the TensorFlow Lite Runtime library are
cross-compiled with Qualcomm Linux and installed on the target device.
The label\_image sample application does the following:
1. Loads a classification TensorFlow Lite model
2. Performs inference on an image using a delegate to accelerate the model on the
Qualcomm hardware
To run a model using the label\_image sample application, do the following:
1. To use a sample model, corresponding labels, and an example image with the
label\_image sample application, download the following:
- BMP file from [here](https://github.com/sourcecode369/tensorflow-1/tree/master/tensorflow/lite/examples/label_image/testdata/)
- MobileNet TensorFlow Lite model from [here](https://github.com/emgucv/models/blob/master/mobilenet_v1_1.0_224_float_2017_11_08/mobilenet_v1_1.0_224.tflite)
2. Run the following commands on the host
machine:
wget http://download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224_quant.tgzCopy to clipboard
tar -xvf mobilenet_v1_1.0_224_quant.tgzCopy to clipboard
wget https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_1.0_224_frozen.tgzCopy to clipboard
tar -xvf mobilenet_v1_1.0_224_frozen.tgzCopy to clipboard
# For SCP, run the following command:
ssh root@[ip-addr]
mount -o remount,rw /
exitCopy to clipboard
scp mobilenet_v1_1.0_224_quant.tflite root@[ip-addr]:/opt/
scp grace_hopper.bmp root@[ip-addr]:/opt/
scp mobilenet_v1_1.0_224/labels.txt root@[ip-addr]:/opt/
scp mobilenet_v1_1.0_224.tflite root@[ip-addr]:/opt/
Copy to clipboard
3. To run an inference using one of the following delegates, do the following:
- To run the model on the Arm^®^ CPU using the XNNPACK delegate, run
the following
command:
label_image -l /opt/labels.txt -i /opt/grace_hopper.bmp -m /opt/mobilenet_v1_1.0_224_quant.tflite -c 10 -p 1 –-xnnpack_delegateCopy to clipboard
- To run the model on the Qualcomm^®^ Adreno™ GPU using the GPU
delegate, run the following
command:
label_image -l /opt/labels.txt -i /opt/grace_hopper.bmp -m /opt/mobilenet_v1_1.0_224.tflite -c 10 -p 1 --gl_backend 1Copy to clipboard
Last Published: Oct 09, 2024
[Previous Topic
Overview](https://docs.qualcomm.com/bundle/publicresource/80-70015-54/topics/tflite-landing-page.md) [Next Topic
Architecture](https://docs.qualcomm.com/bundle/publicresource/80-70015-54/topics/arch.md)