本项目将 timm/efficientnet_b0.ra_in1k 图片分类模型适配到昇腾 NPU (Ascend910) 上运行。使用 ModelScope 下载权重,timm 加载本地权重,包含推理验证、CPU-NPU 精度一致性检查和性能基准测试。
| 项目 | 版本/型号 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| torch | 2.x |
| torch_npu | 2.x |
| timm | latest |
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.010099 |
| mean_abs_error | 0.002107 |
| relative_error | 0.1861% |
| cosine_similarity | 0.999998 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_time | 9.353 ms |
| min_time | 7.998 ms |
| max_time | 20.306 ms |
| p50_time | 8.042 ms |
| p90_time | 20.306 ms |
| p95_time | 20.306 ms |
| throughput | 106.91 images/sec |
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png。
logs/inference.log — 推理输出logs/accuracy.log — 精度一致性结果logs/benchmark.log — 性能基准测试结果logs/env_check.log — 环境检查snapshot_download 下载,严禁使用 pretrained=True 自动从 HuggingFace 下载timm.data.resolve_model_data_config + create_transform 进行预处理.gitignore)#NPU #Ascend #Ascend910 #timm #efficientnet #image-classification