# 使用原生 TensorFlow Lite 示例程序运行 TensorFlow Lite 模型

Source: [https://docs.qualcomm.com/doc/80-70014-54Y/topic/run-a-tensorflow-lite-model-using-a-native-tensorflow-lite-sample-application.html](https://docs.qualcomm.com/doc/80-70014-54Y/topic/run-a-tensorflow-lite-model-using-a-native-tensorflow-lite-sample-application.html)

您可以使用名为 Label Image 的示例 TensorFlow Lite 工具运行 TensorFlow Lite 模型，该工具是 TensorFlow 存储库的一部分。

Label Image 工具与 TensorFlow Lite Runtime 库一起作为 Qualcomm® Linux® 的一部分进行交叉编译，并将这些构件安装到目标设备上。

Label Image 工具执行以下操作：

1. 加载分类 TensorFlow Lite 模型。
2. 使用 delegate 在 Qualcomm 硬件上加速模型，对图像进行推理。

要使用 Label Image 工具运行模型，执行以下操作：

1. 要下载示例模型、相关标签和用于 Label Image 工具的示例图像，运行以下命令：

        ssh root@[ip-addr]
        setenforce 0
        cd /opt/Copy to clipboard

        curl http://download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224_quant.tgz --output /opt/mobilenet_v1_1.0_224_quant.tgzCopy to clipboard

        tar -xvf /opt/mobilenet_v1_1.0_224_quant.tgzCopy to clipboard

        curl https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_1.0_224_frozen.tgz --output  /opt/mobilenet_v1_1.0_224_frozen.tgzCopy to clipboard

        tar -xzf /opt/mobilenet_v1_1.0_224_frozen.tgzCopy to clipboard

        curl https://github.com/sourcecode369/tensorflow-1/tree/master/tensorflow/lite/examples/label_image/testdata/grace_hopper.bmp > /opt/grace_hopper.bmpCopy to clipboard
2. 要使用以下 delegate 之一进行推理，执行以下操作：
    - 要使用 XNNPACK delegate 在 Arm CPU 上运行模型，运行以下命令：

            label_image -l /opt/mobilenet_v1_1.0_224/labels.txt -I /opt/grace_hopper.bmp -m /opt/mobilenet_v1_1.0_224_quant.tflite -c 10 -p 1 – xnnpack_delegate Copy to clipboard
    - 要使用 GPU delegate 在 Qualcomm® Adreno™ GPU 上运行模型，运行以下命令：

            label_image -l /opt/mobilenet_v1_1.0_224/labels.txt -I /opt/grace_hopper.bmp -m /opt/mobilenet_v1_1.0_224.tflite -c 10 -p 1 –gl_backend 1Copy to clipboard

**Parent Topic:** [入门指南](https://docs.qualcomm.com/doc/80-70014-54Y/topic/getting-started.html)

Last Published: Aug 06, 2024

[Previous Topic
使用基于 Gstreamer 的 Qualcomm® Intelligent Multimedia SDK (IM SDK) 运行 TensorFlow Lite 模型](https://docs.qualcomm.com/bundle/publicresource/80-70014-54Y/topics/run-a-tensorflow-lite-model-using-the-gstreamer-based-qim-sdk.md) [Next Topic
架构](https://docs.qualcomm.com/bundle/publicresource/80-70014-54Y/topics/arch.md)