YOLOXm
本示例展示如何把量化后的YOLOXm模型编译,部署到后摩芯片的设备上。
备注
完整的样例代码:https://github.com/houmo-ai/houmo-examples/tree/release_xh2_v1.5.0/models/detection/yolox
模型说明
本例使用的 YOLOX 实现来源 github 开源项目https://github.com/Megvii-BaseDetection/YOLOX/tree/0.3.0。
下载模型后可使用tools目录下的export_onnx.py工具导出为onnx模型,执行命令:
cd YOLOX_HOME
python3 tools/export_onnx.py --output-name yolox_m.onnx -n yolox-m -c yolox_m.pth
YOLOX导出的模型,前面会有多个Slice算子,可以将其统一利用hmatc的图优化功能替换为Conv算子。可以通过在config.yaml配置的model下添加如下配置开启优化。
app_onnx_opt:
optimizer: true
log_level: 0
快速开始
可以通过hmatc工具执行性能测试和精度测试,详细介绍请参考houmo-examples根目录下README.md文件的快速上手章节。
精度评估
量化
hmatc quant -c config.yml -t xh2 # 芯片
编译
hmatc build -c config.yml -t xh2 # 芯片
精度评估
hmatc eval -c config.yml -t xh2 # 芯片
hmatc eval -c config.yml -t xh2 --onnx # onnx
执行完成后会打印模型的数据集精度信息。
性能评估
hmatc perf -c config.yml -t xh2 -wn 10 -sn 1000 -tn 4
执行完成后会打印模型推理延迟、吞吐量等信息。
结果演示
本示例依赖hmatc演示结果,在编译完成的基础上执行:
# xh2
hmatc demo -c config.yml -t xh2
# onnx
hmatc demo -c config.yml -t xh2 --onnx
执行完成后会打印模型的检测结果信息,图片结果将保存在vis_xh2/vis_onnx目录。
参考结果
性能结果
[Latency] Inference avg: 21.441 ms, max: 23.336 ms, min: 13.189 ms, tp99: 22.870 ms, tp999: 23.336 ms
[Latency] Input avg: 2.138 ms, max: 10.335 ms, min: 1.121 ms, tp99: 2.570 ms, tp999: 10.335 ms
[Latency] Output avg: 1.153 ms, max: 5.390 ms, min: 0.657 ms, tp99: 1.393 ms, tp999: 5.390 ms
[Latency] End2end avg: 24.732 ms, max: 28.898 ms, min: 20.409 ms, tp99: 25.279 ms, tp999: 28.898 ms
[Throughput] total: 6201.183 ms, avg: 6.201 ms, repeat: 1000, rounds: 1
[Throughput] qps: 161.260
YOLOXm 模型:https://github.com/Megvii-BaseDetection/YOLOX/tree/0.3.0
COCO 验证集链接: https://cocodataset.org/#download