跳到主要内容

多流批量推理

gst-ai-multistream-batch-inference 同时对多路视频流执行批量 AI 推理(目标检测或图像分割),将流批量化后进行一次推理,提高吞吐量。

Q900 (QCS9075) 最多支持 24 路并发输入(6 批次 × batch-size 4)。

前提条件

步骤

1. 导出批量模型

使用 --batch-size 4 导出 YOLOv8 模型,命令详见 模型导出

将模型和标签推送到设备:

host$
scp yolov8_det.tflite radxa@<device-ip>:/etc/models/

2. 创建配置文件

radxa@airbox$
python3 -c "
import json
with open('/etc/configs/config-multistream-batch-inference.json') as f:
base = json.load(f)
entry = base['pipeline-info'][0]
entry['model-path'] = '/etc/models/yolov8_det.tflite'
entry['labels-path'] = '/etc/labels/yolov8.json'
# 生成 6 批次 × 4 流 = 24 路(id 最大 5)
base['pipeline-info'] = []
for i in range(6):
e = json.loads(json.dumps(entry))
e['id'] = i
base['pipeline-info'].append(e)
with open('/tmp/cfg_batch.json', 'w') as f:
json.dump(base, f, indent=2)
print('24-stream config written')
"

3. 运行

radxa@airbox$
gst-ai-multistream-batch-inference --config-file=/tmp/cfg_batch.json

Ctrl + C 停止。

预期输出

终端输出:

VERBOSE: Replacing 282 out of 282 node(s) with delegate (TfLiteQnnDelegate) node
Pipeline state changed from NULL to READY:
Pipeline state changed from READY to PAUSED:
Pipeline state changed from PAUSED to PLAYING:

显示器上同时显示 24 路检测画面。

验证

  • 全部算子委派到 DSP
  • Pipeline 进入 PLAYING 状态
  • 24 路画面同时正确显示边界框

配置说明

字段说明默认值
output-type输出类型:wayland / filesinkwayland
pipeline-info[].id批次 ID(0-5)0
pipeline-info[].input-type输入源类型file
pipeline-info[].input-file-path输入文件(每批次 4 路)见配置文件
pipeline-info[].mlframework推理框架tflite
pipeline-info[].model-path模型路径需替换为导出模型
pipeline-info[].labels-path标签路径需替换
pipeline-info[].constantsLiteRT 量化常数模型相关
pipeline-info[].post-process-plugin后处理插件:qtimlvdetection / qtimlvsegmentationqtimlvdetection

Pipeline 流程

filesrc × 4 → qtdemux → h264parse → v4l2h264dec → qtibatch (组批)

qtimlvconverter

qtimltflite (DSP 批量推理)

qtimldemux (解复用)

qtimlvdetection / qtimlvsegmentation

qtivcomposer

waylandsink

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

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