本项目将 timm/dpn68.mx_in1k 图片分类模型适配到华为昇腾 NPU (Ascend910) 上运行。使用 ModelScope snapshot_download 下载本地权重,timm.create_model(pretrained=False) 加载模型,通过 torch_npu 在 NPU 上完成推理、精度一致性验证和性能基准测试。
| 项目 | 版本/型号 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| torch | 2.x |
| torch_npu | 适配 CANN 8.5.1 |
| timm | latest |
环境检查日志见 logs/env_check.log。
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.012742 |
| mean_abs_error | 0.002880 |
| relative_error | 0.3112% |
| cosine_similarity | 0.999995 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_time | 8.888 ms |
| min_time | 8.790 ms |
| max_time | 8.953 ms |
| p50_time | 8.901 ms |
| p90_time | 8.953 ms |
| p95_time | 8.953 ms |
| images_per_sec | 112.51 |
测试条件:单卡 Ascend910,batch=1,10 次正式运行(2 次预热)。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png 与 screenshots/self_verification.txt。
logs/inference.log — 推理结果logs/accuracy.log — CPU-NPU 精度一致性logs/benchmark.log — 性能基准测试logs/env_check.log — 环境检查snapshot_download 因网络问题失败,可手动下载后放入缓存目录。*.bin / *.safetensors / *.pth / *.pt / *.ckpt / *.onnx 提交到 Git 仓库。#NPU #Ascend #Ascend910 #timm #image-classification