# 前提条件

Source: [https://docs.qualcomm.com/doc/80-70022-50SC/topic/download-model-and-label-files.html](https://docs.qualcomm.com/doc/80-70022-50SC/topic/download-model-and-label-files.html)

在运行 AI/ML 示例应用程序之前，请完成这些前提条件。

1. 在您的 Qualcomm Linux 或 Ubuntu 主机上启用 SSH，以使用 SSH 登录并连接到目标设备。有关说明，请参阅：
    - [使用 SSH 登录](https://docs.qualcomm.com/bundle/publicresource/topics/80-70022-254/how_to.html#use-ssh) Qualcomm Linux
    - [使用 SSH 登录](https://docs.qualcomm.com/bundle/publicresource/topics/80-90441-1/Use_Ubuntu_on_RB3_Gen2_3.html#sign-in-to-the-rb3-gen-2-console-using-ssh) Ubuntu Server

Note: 如果已设置 SSH 并连接 Wi-Fi，请跳过此步骤。
2. 使用 SSH 登录目标设备：
    - 对于 Qualcomm Linux：

            ssh root@<ip address of target device>Copy to clipboard
    - 对于 Ubuntu Server：

            ssh ubuntu@<ip address of target device> Copy to clipboard
3. 下载自动化脚本，用于将模型和标签文件下载到目标设备上的 etc/models 和 etc/labels 目录：

        curl -L -O https://raw.githubusercontent.com/quic/sample-apps-for-qualcomm-linux/refs/heads/main/download_artifacts.shCopy to clipboard
4. 在目标设备上设置脚本权限：

        chmod +x download_artifacts.shCopy to clipboard
5. 提供所需的参数来运行脚本，在目标设备上下载模型和标签文件：

        ./download_artifacts.sh -v GA1.6-rel -c <soc name>Copy to clipboard

    这里，将 `<soc name>` 替换为 `QCS6490`、`QCS9075` 或 `QCS8275`。

Note: 对于 Ubuntu Server，此步骤需要 `sudo` 访问权限。
6. YOLOv8 模型默认不可用。您可以使用以下选项通过脚本下载模型或使用 Linux 主机上的 Qualcomm AI Hub API 导出模型。 
    如果使用的是[多流批量推理](https://docs.qualcomm.com/doc/80-70022-50SC/topic/multistream-batch-inference.html)应用程序，则可以生成批量模型。

    1. 使用脚本下载模型：
        1. 创建 [Qualcomm AI Hub 帐户](https://app.aihub.qualcomm.com/account/)。
        2. 选择账户名，然后转到右上角的 Settings，选择 API 令牌。
        3. 在 Linux 主机上导出模型并设置所需的权限：

                curl -L -O https://raw.githubusercontent.com/quic/sample-apps-for-qualcomm-linux/refs/heads/main/scripts/export_model.shCopy to clipboard

                chmod +x export_model.shCopy to clipboard

            将 <var class="keyword varname">API_TOKEN</var> 替换为所选密钥：

                ./export_model.sh --api-token=<API_TOKEN>Copy to clipboard
    2. 使用 Qualcomm AI Hub API 导出 [YOLOv8-Detection-Quantized](https://github.com/quic/ai-hub-models/tree/main/qai_hub_models/models/yolov8_det) 模型。
在从 `export_model.sh` 创建的 python 环境中运行以下命令。例如，要导出 YOLOv8 LiteRT 模型：

            python -m qai_hub_models.models.yolov8_det.export --quantize w8a8 --target-runtime=tflite --chipset="qualcomm-qcs6490-proxy"Copy to clipboard
    3. 生成批量模型。 
        要更改模型的批量大小，请更新以下 `export` 命令中的 <var class="keyword varname">&lt;N&gt;</var>：

            python -m qai_hub_models.models.<Model_Name>.export --batch-size <N> --device "QCS6490 (Proxy)"Copy to clipboard

例如，要导出包含 `--batch-size
                                    4` 的 YOLOv8 LiteRT 模型，请从 `export_model.sh` 创建的 Python 环境中运行以下命令：

            python -m qai_hub_models.models.yolov8_det.export --quantize w8a8 --target-runtime=tflite --chipset="qualcomm-qcs6490-proxy" --batch-size 4Copy to clipboard

例如，要导出 YOLOv8 QNN 模型，请从 `export_model.sh` 创建的 Python 环境中运行以下命令：

            python -m qai_hub_models.models.yolov8_det.export --quantize w8a8 --target-runtime=qnn_context_binary --chipset="qualcomm-qcs6490-proxy" --compile-options="--qairt_version 2.38" --profile-options "--qairt_version 2.38"Copy to clipboard
7. 使用步骤 5 中的下载脚本在目标设备的 `video.mp4` 目录中获取示例 `/etc/media ` 文件。如果您使用的是自定义视频，请确保将视频推送到 `/etc/media`，并更新应用程序的 `config.JSON` 文件中的文件路径。
8. 使用 HDMI 端口将显示器连接到目标设备。有关说明，请参见[设置 HDMI 显示器](https://docs.qualcomm.com/bundle/publicresource/topics/80-70022-18/samples.html)。
9. 在目标设备的终端中，在 SSH shell 中运行以下命令以激活显示器：
    - 对于 Qualcomm Linux：

            export XDG_RUNTIME_DIR=/dev/socket/weston && export WAYLAND_DISPLAY=wayland-1Copy to clipboard
    - 对于 Ubuntu Server：

            export XDG_RUNTIME_DIR=/run/user/$(id -u ubuntu)/ && export WAYLAND_DISPLAY=wayland-1Copy to clipboard

## 故障排除

- 如果您遇到摄像头或显示器问题，请参阅[摄像头问题排查](https://docs.qualcomm.com/bundle/publicresource/topics/80-70022-17/troubleshooting.html)和[显示问题排查](https://docs.qualcomm.com/bundle/publicresource/topics/80-70022-18/debug.html)。
- 如果下载脚本文件后任何模型不可用，您可以从 [IoT–Qualcomm AI Hub](https://aihub.qualcomm.com/iot/models/) 下载模型并将其推送到目标设备：

        scp <model filename> root@<IP addr of the target device>:/etc/modelsCopy to clipboard

例如：

        scp mobilenet_v2_quantized.tflite root@<IP addr of the target device>:/etc/modelsCopy to clipboard
- 要从 UART shell 运行示例应用程序，请使用读/写权限重新挂载文件系统，并在目标设备上执行以下命令：
    - 对于 Qualcomm Linux：

            mount -o remount,rw /usrCopy to clipboard
    - 对于 Ubuntu Server：

            mount -o remount,rw /Copy to clipboard
- 对于 Ubuntu Server，将模型文件复制到用户 `home` 文件夹，然后使用 `sudo` 命令将文件复制到 `/etc/models` 目录：

        scp <modelfilename> ubuntu@<IP addr of the target device>:/home/ubuntu
        ssh ubuntu@<IP addr of the target device>
        sudo cp /home/ubuntu/<model filename> /etc/modelsCopy to clipboard

**Parent Topic:** [运行 AI/ML 示例应用程序](https://docs.qualcomm.com/doc/80-70022-50SC/topic/ai-ml-sample-applications.html)

Last Published: Nov 05, 2025

[Previous Topic
运行 AI/ML 示例应用程序](https://docs.qualcomm.com/bundle/publicresource/80-70022-50SC/topics/ai-ml-sample-applications.md) [Next Topic
图像分类](https://docs.qualcomm.com/bundle/publicresource/80-70022-50SC/topics/gst-ai-classification.md)