本文档记录 RetinaFace ResNet50 人脸检测模型在昇腾 NPU (Ascend 910B3) 上的迁移适配与精度验证结果。
RetinaFace 是基于 ResNet50+FPN 骨干网络的单阶段人脸检测器,通过多任务学习同时预测人脸边界框、置信度和关键点。本适配使用模型的 net(RetinaFace 主干网络)直接在 NPU 上推理,图像预处理(均值减除)在 CPU 完成。
相关获取地址:
| 组件 | 版本 |
|---|---|
CANN | 8.5.1 |
torch | 2.8.0 |
torch_npu | 2.8.0.post4 |
modelscope | 1.37.0 |
torchvision | 0.23.0 |
Ascend 910B3,单卡推理pip install torch==2.8.0 torch_npu==2.8.0.post4 torchvision modelscope opencv-python-headless numpypython inference.py --image face.jpg --device npu(16800, 4) 检测框,正常| 指标 | CPU | NPU (Ascend 910B3) |
|---|---|---|
| 平均耗时 | 7515.3 ms | 15.8 ms |
| 中位耗时 | 7564.0 ms | 15.8 ms |
| 加速比 | — | 475.0x |
| 指标 | 数值 |
|---|---|
| 输出形状 | (16800, 4) |
| 鲁棒平均相对误差 | 0.1916% |
| 精度评测 | 通过 (< 1%) |
detector.net 获取 RetinaFace 主干网络,绕过 detector.forward 中的 img -= (104,117,123) 广播问题(NPU 不支持 tuple 广播)