facebook/regnet-x-080 on Ascend NPU
1. 简介
本文档记录了 facebook/regnet-x-080 模型在华为昇腾 NPU (Ascend910) 上的适配过程和验证结果。
RegNet-X 是 Meta 提出的基于规则的网络架构,通过设计空间搜索得到的高效卷积神经网络。X 变体使用标准卷积操作。
2. 验证环境
- 硬件: 华为昇腾 910 NPU
- 软件: CANN 8.5.1, PyTorch 2.x, torch_npu
- 操作系统: Linux
- 模型来源: ModelScope (facebook/regnet-x-080)
- 权重格式: pytorch_model.bin
3. 推理运行
pip install -r requirements.txt
python inference.py
推理结果 (NPU Top-5):
- Top-1: hand-held computer, hand-held microcomputer (0.4241)
- Top-2: binder, ring-binder (0.1405)
- Top-3: handkerchief, hankie, hanky, hankey (0.0926)
- Top-4: crossword puzzle, crossword (0.0894)
- Top-5: scoreboard (0.0445)
日志保存在 logs/inference.log。
4. 精度验证
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|
| max_abs_error | 0.006932 |
| mean_abs_error | 0.001062 |
| relative_error | 0.0441% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
- CPU Top-1: hand-held computer, hand-held microcomputer
- NPU Top-1: hand-held computer, hand-held microcomputer
- CPU Top-5: hand-held computer, binder, handkerchief, crossword puzzle, scoreboard
- NPU Top-5: hand-held computer, binder, handkerchief, crossword puzzle, scoreboard
- Top-1 match: True
- Top-5 match: True
5. 性能参考
| 指标 | 数值 |
|---|
| avg_latency | 7.45 ms |
| min_latency | 7.28 ms |
| max_latency | 7.66 ms |
| throughput | 134.28 images/sec |
6. 精度评测说明
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
7. 自验证截图
详见 screenshots/self_verification.png 和 screenshots/self_verification.txt。
8. 日志文件
logs/env_check.log - NPU 环境检查
logs/inference.log - 推理结果
logs/accuracy.log - 精度验证
logs/benchmark.log - 性能测试
9. 注意事项
- 本适配使用 ModelScope snapshot_download 下载权重,避免直接从 HuggingFace 下载
- 模型使用 transformers AutoModelForImageClassification 加载
- 精度验证采用单图 smoke test,非完整 ImageNet 验证集评测
- NPU 推理结果与 CPU 结果高度一致,相对误差 < 1.0%
10. 标签
#NPU #Ascend #Ascend910 #RegNet #ImageClassification #facebook