# 定制示例程序

需要设置 eSDK (extensible SDK) 才能开发应用程序/插件代码。有关设置 eSDK 以及下载和编译源代码的说明，请参阅[编译应用程序和 Qualcomm IM SDK](https://docs.qualcomm.com/doc/80-70017-15BY/topic/compile-application-qualcomm-im-sdk.html)。

有关如何下载源代码以及编译定制示例程序的说明，可参见[开发您自己的应用程序](https://docs.qualcomm.com/doc/80-70017-15BY/topic/develop-your-own-application.html)。

按照说明[下载 QualcommNeural Processing SDK 的模型文件](https://docs.qualcomm.com/doc/80-70017-15BY/topic/default-reference-app.html#download-model-files-for-qualcomm-neural-processing-sdk)，然后再继续执行后续步骤。

## 示例 1：定制训练的 YoloV8 TFLite 模型

Qualcomm IM SDK 示例程序使用 YoloV8 模型进行目标检测。此示例说明了如何尝试自定义经训练的 YoloV8 变体。

按以下步骤操作，通过现有示例程序来运行用户自己的定制训练的 YoloV8 模型。

1. 将示例程序中的现有模型替换为新模型。
2. 使用定制标签来修改标签文件。
3. 使用示例程序来运行修改后的模型。

### 修改定制的 YoloV8 模型的标签

使用 Qualcomm IM SDK 及其示例程序时，程序需要使用特定格式的标签。您需要更新此标签文件中每个标签的 `<label_name>`、`<hex_value_for_label_id>` 和 `<hex_value_for_color>` 值。

标签文件中每个标签的格式应遵循下方所示的模板。

(structure)"<label_name>,id=(guint)<hex_value_for_label_id>,color=(guint)<hex_value_for_color>;"
    Copy to clipboard

例如：

(structure)"person,id=(guint)0x0,color=(guint)0x00FF00FF;"
    (structure)"bicycle,id=(guint)0x1,color=(guint)0x00FF00FF;"
    (structure)"car,id=(guint)0x2,color=(guint)0x0000FFFF;"
    (structure)"motorcycle,id=(guint)0x3,color=(guint)0x00FF00FF;"
    Copy to clipboard

如需使用 TFLite runtime 运行目标检测模型，可在命令行参数中指定定制训练模型以及定制标签文件，然后运行以下命令。

1. 将模型复制到设备。

scp yolov8_custom.tflite root@<IP address of the target device>:/opt/
        Copy to clipboard
2. 将标签复制到设备。

scp yolov8_custom.labels root@<IP address of the target device>:/opt/
        Copy to clipboard

3. 登录设备。

ssh root@<IP address of the target device>
        Copy to clipboard
4. 修改如图所示的 `/opt/config_detection.json` 文件。

{
        "file-path": "/opt/video.mp4",
        "ml-framework": "tflite",
        "yolo-model-type": "yolov8",
        "model": "/opt/yolov8_custom.tflite",
        "labels": "/opt/yolov8_custom.labels",
        "constants": "<constants for custom YOLOv8 model>",
        "threshold": 40,
        "runtime": "dsp"
        }
        Copy to clipboard
5. 运行示例应用程序。

gst-ai-object-detection --config-file=/opt/config_detection.json
        Copy to clipboard

### 注释

- 如需显示可用的帮助选项，可运行以下命令：

gst-ai-object-detection -h
        Copy to clipboard
- 如需停止用例，可按下 <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">CTRL</kbd>+<kbd class="kbd docutils literal notranslate">C</kbd></kbd>。

Last Published: Jan 25, 2026

[Previous Topic
注释](https://docs.qualcomm.com/bundle/publicresource/80-70017-15BY/topics/default-reference-app.md) [Next Topic
开发您自己的应用程序](https://docs.qualcomm.com/bundle/publicresource/80-70017-15BY/topics/develop-your-own-application.md)