# 在应用程序中集成 AI Hub 模型

本节介绍如何在参考应用程序中使用 AI Hub 模型。此示例使用来自 AI Hub 的图像分类模型。

Note

大多数公开的图像分类模型的预处理和后处理都类似，并且可能由 `qtimlpostprocess` 插件支持。

Qualcomm AI Hub 为 Qualcomm 设备提供优化的 AI 模型，允许它们使用 LiteRT（以前称为 Tensorflow Lite）或 Qualcomm® AI Engine Direct 在 CPU、GPU 或 NPU 上运行。

此示例说明如何使用 AI Hub 中的 [inception_v3](https://aihub.qualcomm.com/iot/models/inception_v3) 模型并将该模型集成到 `gst-ai-classification` 参考应用程序中。

| **编号** | **示例程序** | **经过验证的 AI Hub 模型** | **标签文件** |
| --- | --- | --- | --- |
| 1 | gst-ai-classification | GoogLeNet | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/classification.json) |
| 2 | gst-ai-classification | inception\_v3 | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/classification.json) |
| 3 | gst-ai-classification | mobilenet-v2 | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/classification.json) |
| 4 | gst-ai-classification | MobileNet-v3-Large | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/classification.json) |
| 5 | gst-ai-classification | ResNet101 | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/classification.json) |
| 6 | gst-ai-classification | SqueezeNet-1\_1 | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/classification.json) |
| 7 | gst-ai-classification | ResNet18 | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/classification.json) |
| 8 | gst-ai-classification | ResNeXt50 | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/classification.json) |
| 9 | gst-ai-classification | WideResNet50 | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/classification.json) |
| 10 | gst-ai-classification | Shufflenet-v2 | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/classification.json) |
| 11 | gst-ai-classification | ResNeXt101 | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/classification.json) |
| 12 | gst-ai-segmentation | deeplabv3\_plus\_mobilenet | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/deeplabv3_resnet50.json) |
| 13 | gst-ai-segmentation | fcn\_resnet50 | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/deeplabv3_resnet50.json) |
| 14 | gst-ai-segmentation | ffnet\_40s | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/deeplabv3_resnet50.json) |
| 15 | gst-ai-segmentation | ffnet\_54s | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/deeplabv3_resnet50.json) |
| 16 | gst-ai-segmentation | ffnet\_78s | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/deeplabv3_resnet50.json) |
| 17 | gst-ai-object-detection | Yolo-v7 | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/yolox.json) |
| 18 | gst-ai-object-detection | YOLOv8-Detection | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/yolox.json) |
| 19 | GST-AI-superresolution | QuickSRNetLarge | 不适用 |
| 20 | GST-AI-superresolution | QuickSRNetMedium | 不适用 |
| 21 | GST-AI-superresolution | QuickSRNetSmall | 不适用 |
| 22 | GST-AI-superresolution | XLSR | 不适用 |
| 23 | gst-ai-monodepth | Midas-V2 | [标签](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/monodepth.json) |
| 24 | gst-ai-pose-detection | HRNetPose | <ul class="simple"><br><li><p><a href="https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/hrnet_pose.json" class="xref cursorpointer" onclick="Window.BookmapComponent.navigateExternalFile('https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/hrnet_pose.json')">标签</a></p></li><br><li><p><a href="https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/hrnet_settings.json" class="xref cursorpointer" onclick="Window.BookmapComponent.navigateExternalFile('https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/hrnet_settings.json')">设置</a></p></li><br></ul> |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |
|  |  |  |  |

Note

某些模型在 AI Hub 上只有 LiteRT 或 Qualcomm AI Engine Direct SDK 模型。不过，AI Hub 经常更新其中的库以包含更多模型并增强现有模型。

前提条件

1. 下载 [AI Hub 模型](https://aihub.qualcomm.com/iot/models/inception_v3)。

    1. 在搜索栏中搜索模型并选择模型。
    2. 选择要为其下载模型的 runtime、精度和设备。

        - runtime：*TFLite*
        - 精度：*w8a8*
        - 设备：

            - Qualcomm Dragonwing™ RB3 Gen 2: *Qualcomm QCS6490*
            - Qualcomm Dragonwing™ IQ-9075: *Qualcomm QCS9075*
2. 将与型号匹配的标签文件复制到设备。

> 
> 
> 标签文件可通过提供的[链接](https://github.com/quic/sample-apps-for-qualcomm-linux/blob/main/artifacts/json_labels/)下载。

Note

以下部分对通过 AI Hub 下载的模型使用占位符模型名称。将命令中的模型名称更新为通过 AI Hub 下载的相应模型名称。

## 修改配置

1. 将模型复制到设备。

scp inception_v3-inception-v3-w8a8.tflite root@<IP address of the target device>:/etc/models/
        Copy to clipboard
2. 将标签复制到设备。

wget https://raw.githubusercontent.com/quic/sample-apps-for-qualcomm-linux/refs/heads/main/artifacts/json_labels/classification.json
        Copy to clipboard

scp classification.json root@<IP addr of the target device>:/etc/labels/
        Copy to clipboard
3. 更新 `/etc/configs/config_classification.json` 文件，如下所示。

{
        "file-path": "/etc/media/video.mp4",
        "ml-framework": "tflite",
        "model": "/etc/models/inception_v3-inception-v3-w8a8.tflite",
        "labels": "/etc/labels/classification.json",
        "threshold": 40,
        "runtime": "dsp"
        }
        Copy to clipboard

## 运行示例应用程序

1. 运行以下命令，为显示器启用 Weston 服务：

export XDG_RUNTIME_DIR=/dev/socket/weston && export WAYLAND_DISPLAY=wayland-1
        Copy to clipboard
2. 在命令行参数中指定常量值，运行示例程序：

gst-ai-classification --config-file=/etc/configs/config_classification.json
        Copy to clipboard
3. 使用示例应用程序在用户的设备上运行各种 AI Hub 模型。运行不同的 AI Hub 模型：

    1. 下载您想要运行的模型和标签文件。
    2. 将模型和标签文件复制到设备。
    3. 按照以下步骤运行示例应用程序。

Tab gst-ai-object-detection
Tab gst-ai-segmentation
Tab gst-ai-superresolution

1. 下载 [Yolox Quantized LiteRT 模型文件](https://aihub.qualcomm.com/iot/models/yolox)（用于目标检测）。
        2. 更新 `/etc/configs/config_detection.json` 文件，如下所示。

{
                "file-path": "/etc/media/video.mp4",
                "ml-framework": "tflite",
                "yolo-model-type": "yolox",
                "model": "/etc/models/yolox_quantized.tflite",
                "labels": "/etc/labels/yolox.json",
                "threshold": 40,
                "runtime": "dsp"
                }
                Copy to clipboard

Note

根据您获取的模型，更新配置文件中的模型名称。
        3. 运行示例应用程序。

Note

确保您已将模型和标签文件复制至设备。

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

1. 更新 `/etc/configs/config_segmentation.json` 文件如下：

            使用 `deeplabv3_plus_mobilenet_quantized.tflite` 模型文件（用于分割）和 `deeplabv3_resnet50.json` 文件作为示例。

{
                "file-path": "/etc/media/video.mp4",
                "ml-framework": "tflite",
                "model": "/etc/models/deeplabv3_plus_mobilenet_quantized.tflite",
                "labels": "/etc/labels/deeplabv3_resnet50.json",
                "runtime": "dsp"
                }
                Copy to clipboard
        2. 运行示例应用程序。

gst-ai-segmentation --config-file=/etc/configs/config_segmentation.json
                Copy to clipboard

1. 更新 `/etc/configs/config-superresolution.json` 文件，如下所示。

{
                "input-file-path": "/etc/media/super.mp4",
                "model": "/etc/models/quicksrnetsmall_quantized.tflite",
                "output-file-path":"/etc/media/out.mp4"
                }
                Copy to clipboard
        2. 运行示例应用：

gst-ai-superresolution --config-file=/etc/configs/config-superresolution.json
                Copy to clipboard

Note

确保使用的视频具有 128x128 分辨率，作为模型的输入。

        如需了解更多输入参数的详细信息，请参阅应用程序的帮助部分。

Note

在进行分割的情况下，未被识别的对象可能会以白色背景显示。该问题源于标签文件，将在未来的更新中得到解决。
4. 如需进行任何更改，可重新编译示例程序并运行。关于如何使用 eSDK 编译参考应用程序的说明，请参阅 [Qualcomm Intelligent Multimedia 软件开发包 (IM SDK) 快速入门指南](https://docs.qualcomm.com/bundle/publicresource/topics/80-70022-51/introduction.html)。

Last Published: Nov 05, 2025

[Previous Topic
在应用程序中集成定制 AI 模型](https://docs.qualcomm.com/bundle/publicresource/80-70022-15BY/topics/integrate-custom-model.md) [Next Topic
为定制模型添加后处理支持](https://docs.qualcomm.com/bundle/publicresource/80-70022-15BY/topics/add-postprocessing-support-custom-model.md)

Source: [https://docs.qualcomm.com/doc/80-70022-15BY/topic/integrate-ai-hub-models.html](https://docs.qualcomm.com/doc/80-70022-15BY/topic/integrate-ai-hub-models.html)