# 运行机器学习用例

Source: [https://docs.qualcomm.com/doc/80-70022-50SC/topic/machine-learning-use-cases.html](https://docs.qualcomm.com/doc/80-70022-50SC/topic/machine-learning-use-cases.html)

在机器学习用例中使用 LiteRT 和 Qualcomm Neural Processing SDK runtime 进行推理。

在运行用例之前，请执行以下操作：

- 完成 [GStreamer 命令行用例](https://docs.qualcomm.com/doc/80-70022-50SC/topic/gstreamer-application-use-cases.html)中提到的前提条件。
- [前提条件](https://docs.qualcomm.com/doc/80-70022-50SC/topic/download-model-and-label-files.html)。

Important: 本指南中的 AI 程序与 Qualcomm AI Runtime SDK v2.38 和 LiteRT（或 TFLite）v2.16.1 兼容。在开始 AI/ML 开发之前，请确保将匹配的 SDK 下载到主机。

上述用例使用 MobileNet TFLite 模型对单摄像头流的场景进行分类，并叠加或组合分类标签。 
Note: 这些说明已在 Ubuntu 22.04 主机上验证。

1. 创建 Python 3.10 虚拟环境：

        sudo apt-get install python3.10Copy to clipboard

        python3.10 -m venv py3.10Copy to clipboard

        source py3.10/bin/activateCopy to clipboard
2. 生成 yolov5.tflite 模型：

        git clone https://github.com/ultralytics/yolov5.gitCopy to clipboard

        cd yolov5Copy to clipboard

        python -m pip install -r requirements.txt tensorflow-cpuCopy to clipboard

        python export.py --weights yolov5m.pt --img 320 --include tflite --int8 --data data/coco128.yamlCopy to clipboard
3. 将模型推送到目标设备：
    - 对于 Qualcomm Linux：

            scp yolov5m-int8.tflite root@<IP address of the device>:/etc/models/yolov5.tfliteCopy to clipboard
    - 对于 Ubuntu Server：

            scp yolov5m-int8.tflite ubuntu@<IP address of the device>:/home/ubuntu
            ssh ubuntu@<IP address of the device>
            sudo cp /home/ubuntu/yolov5.tflite /etc/modelsCopy to clipboard

YOLO-NAS 和 YOLOv5 模型基于同一数据集训练。YOLOv5 需使用相同的标签文件。
- 对于 Qualcomm Linux：

        ssh root@<ip-addr of the target device>Copy to clipboard

        cp /etc/labels/yolox.json /etc/labels/yolov5.json Copy to clipboard
- 对于 Ubuntu Server：

        ssh ubuntu@<IP address of the device>
        sudo cp /etc/labels/yolonas.labels /etc/labels/yolov5.labelsCopy to clipboard

- **[LiteRT 用例](https://docs.qualcomm.com/doc/80-70022-50SC/topic/tensorflow-lite-use-cases.html)**  

LiteRT 是一套支持设备端机器学习的工具集。您可以在移动、嵌入式和边缘设备上运行模型。借助 LiteRT 用例，您可以运行图像分类、目标检测、图像分割和姿态估计等用例。
- **[Qualcomm Neural Processing SDK 用例](https://docs.qualcomm.com/doc/80-70022-50SC/topic/qualcomm-neural-processing-sdk-use-cases.html)**  

Qualcomm Neural Processing SDK（原称为 Qualcomm Snapdragon Neural Processing Engine (SNPE)）用于运行深度神经网络进行推理。这些用例描述了使用不同 ML 模型的图像分类、目标检测和图像分割场景。

**Parent Topic:** [GStreamer 命令行用例](https://docs.qualcomm.com/doc/80-70022-50SC/topic/gstreamer-application-use-cases.html)

Last Published: Nov 05, 2025

[Previous Topic
GStreamer 命令行用例](https://docs.qualcomm.com/bundle/publicresource/80-70022-50SC/topics/gstreamer-application-use-cases.md) [Next Topic
LiteRT 用例](https://docs.qualcomm.com/bundle/publicresource/80-70022-50SC/topics/tensorflow-lite-use-cases.md)