本文档记录 DamoYOLO TinyNAS 安全帽检测模型在昇腾 NPU (Ascend 910B3) 上的迁移适配与精度验证结果。
本模型与同系列 DamoYOLO 模型(人头检测、人体检测、无人机检测)共享相同的 TinyNAS 骨干网络 + GiraffeNeckV2 颈部 + ZeroHead 检测头架构,差异仅在于训练数据——本模型针对工地安全帽佩戴场景进行训练。
相关获取地址:
参考文档:
cv_tinynas_head-detection_damoyolo-ascend/README.md| 组件 | 版本 |
|---|---|
CANN | 8.5.1 |
torch | 2.8.0 |
torch_npu | 2.8.0.post4 |
modelscope | 1.37.0 |
timm | latest |
opencv-python-headless | 4.13.0 |
Ascend 910B3,单卡推理[1, 3, 640, 640] RGB 图像pip install torch==2.8.0 torch_npu==2.8.0.post4 \
-i https://mirrors.huaweicloud.com/repository/pypi/simple \
--trusted-host mirrors.huaweicloud.com
pip install modelscope==1.37.0 opencv-python-headless numpy \
timm thop easydict matplotlib \
-i https://mirrors.huaweicloud.com/repository/pypi/simple \
--trusted-host mirrors.huaweicloud.commodelscope download --model damo/cv_tinynas_object-detection_damoyolo_safety-helmet \
--local_dir ./cv_tinynas_object-detection_damoyolo_safety-helmetpython inference.py --image construction_site.jpg --device npufrom inference import run_inference
result = run_inference("construction_site.jpg", device="npu")
print(f"检测到 {len(result['boxes'])} 个目标, 耗时 {result['time_ms']:.1f}ms")python evaluate.py验证结果:
[1, 128, 80, 80],正常DetectionOutput,包含 boxes 和 scores 字段测试条件:input [1, 3, 640, 640],10 轮取平均。
| 指标 | CPU | NPU (Ascend 910B3) |
|---|---|---|
| 平均耗时 (完整模型) | ~4200 ms | ~27 ms |
| 加速比 | — | 156x |
对比 CPU (PyTorch) 与 NPU (torch_npu) 在相同随机输入下骨干网络 (TinyNAS backbone) 的输出特征图。
| 指标 | 数值 |
|---|---|
| 特征图形状 | [1, 128, 80, 80] |
| 鲁棒平均相对误差 | 0.187% |
| 精度要求 | 平均相对误差 < 1% |
| 精度评测 | 通过 |
timm、thop、easydict,首次加载需 trust_remote_code=True--model_dirDetectionOutput 含 boxes/scores