z
zkx_/cv_resnet50_face-detection_retinaface-ascend
模型介绍文件和版本Pull Requests讨论分析

cv_resnet50_face-detection_retinaface on Ascend NPU

1. 简介

本文档记录 RetinaFace ResNet50 人脸检测模型在昇腾 NPU (Ascend 910B3) 上的迁移适配与精度验证结果。

RetinaFace 是基于 ResNet50+FPN 骨干网络的单阶段人脸检测器,通过多任务学习同时预测人脸边界框、置信度和关键点。本适配使用模型的 net(RetinaFace 主干网络)直接在 NPU 上推理,图像预处理(均值减除)在 CPU 完成。

相关获取地址:

  • 权重下载地址(ModelScope):https://modelscope.cn/models/damo/cv_resnet50_face-detection_retinaface

2. 验证环境

组件版本
CANN8.5.1
torch2.8.0
torch_npu2.8.0.post4
modelscope1.37.0
torchvision0.23.0
  • NPU:Ascend 910B3,单卡推理
  • 模型大小:约 27.3M 参数

3. 推理启动

pip install torch==2.8.0 torch_npu==2.8.0.post4 torchvision modelscope opencv-python-headless numpy
python inference.py --image face.jpg --device npu

4. Smoke 验证

  • CPU 推理输出 (16800, 4) 检测框,正常
  • NPU 推理输出同形状,正常

5. 性能参考

指标CPUNPU (Ascend 910B3)
平均耗时7515.3 ms15.8 ms
中位耗时7564.0 ms15.8 ms
加速比—475.0x

6. 精度评测

指标数值
输出形状(16800, 4)
鲁棒平均相对误差0.1916%
精度评测通过 (< 1%)

7. 注意事项

  1. 使用 detector.net 获取 RetinaFace 主干网络,绕过 detector.forward 中的 img -= (104,117,123) 广播问题(NPU 不支持 tuple 广播)
  2. 图像预处理(BGR→RGB、resize 640×640、均值减除)在 CPU 完成后再送入 NPU
  3. 完整人脸检测流水线需后处理(NMS、置信度过滤)在 CPU 执行
下载使用量0