跳到主要内容

图像分割

gst-ai-segmentation 对视频流逐帧执行语义分割,为每个像素分配类别标签,以半透明彩色蒙版叠加渲染。

使用 DeepLabV3+ MobileNet 模型。

目标检测 的区别:检测用边界框框出物体,分割对每个像素分类并着色。

前提条件

步骤

1. 确认模型和标签

radxa@airbox$
ls -l /etc/models/deeplabv3_plus_mobilenet_quantized.tflite
ls -l /etc/labels/deeplabv3_resnet50.json

2. 查看配置

radxa@airbox$
cat /etc/configs/config_segmentation.json

关键字段:

字段默认值说明
file-path/etc/media/video.mp4输入视频路径
ml-frameworktflite推理框架
model/etc/models/deeplabv3_plus_mobilenet_quantized.tflite模型文件
labels/etc/labels/deeplabv3_resnet50.json颜色映射文件
runtimedsp推理硬件
video-dispositionstretch视频布局方式

3. 运行

radxa@airbox$
gst-ai-segmentation --config-file=/etc/configs/config_segmentation.json

Ctrl + C 停止。

预期输出

终端输出:

Running app with model: /etc/models/deeplabv3_plus_mobilenet_quantized.tflite and labels: /etc/labels/deeplabv3_resnet50.json
Using DSP Delegate
VERBOSE: Replacing 136 out of 136 node(s) with delegate (TfLiteQnnDelegate) node, yielding 1 partitions for the whole graph.
Pipeline state changed from PAUSED to PLAYING

显示器上播放测试视频,画面叠加半透明彩色分割蒙版。不同颜色对应不同类别(人、车、道路、建筑等)。

验证

  • Using DSP Delegate:推理在 NPU 上运行
  • Replacing 136 out of 136 node(s):全部 136 个算子委派到 DSP
  • Pipeline 进入 PLAYING 状态
  • 显示器正确显示分割蒙版

排障

分割蒙版不显示

确认标签文件内容有效:

radxa@airbox$
python3 -c "import json; json.load(open('/etc/labels/deeplabv3_resnet50.json'))" && echo "JSON 有效"

如果输出 404: Not Found 或其他非 JSON 内容,重新运行下载脚本。

    您需要登录 GitHub 才能发表评论。如果您已登录,请忽略此消息。

    Radxa-docs © 2026 by Radxa Computer (Shenzhen) Co.,Ltd. is licensed under CC BY 4.0