本项目将 timm/mobilevitv2_100.cvnets_in1k 图片分类模型适配到昇腾 NPU (Ascend910) 上运行。使用 ModelScope snapshot_download 下载权重,通过 timm.create_model(..., pretrained=False) 加载本地权重,确保完全脱离 HuggingFace 自动下载。适配过程包含单图推理验证、CPU-NPU 精度一致性检查和性能基准测试。
| 项目 | 版本/型号 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| torch | 2.x |
| torch_npu | 对应 CANN 版本 |
| timm | latest |
| modelscope | latest |
NPU 状态(npu-smi info)显示设备健康,AICore 空闲,HBM 可用。
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.008415 |
| mean_abs_error | 0.001859 |
| relative_error | 0.2127% |
| cosine_similarity | 0.999998 |
| threshold | 1.0% |
| 结果 | PASS |
在单卡 Ascend910 上运行 10 次推理(2 次预热后)的统计结果:
| 指标 | 数值 |
|---|---|
| avg_latency_ms | 7.428 |
| min_latency_ms | 7.128 |
| max_latency_ms | 8.058 |
| p50_latency_ms | 7.182 |
| p90_latency_ms | 8.058 |
| p95_latency_ms | 8.058 |
| images_per_sec | 134.62 |
日志保存在 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png 和 screenshots/self_verification.txt。
logs/env_check.log — NPU 环境检查logs/inference.log — NPU 推理 Top-5 结果logs/accuracy.log — CPU-NPU 精度一致性logs/benchmark.log — NPU 性能基准timm.create_model(..., pretrained=True),必须通过 ModelScope 下载本地权重。*.bin, *.safetensors, *.pth, *.pt, *.ckpt, *.onnx)已加入 .gitignore,不会提交到仓库。#NPU #Ascend #Ascend910 #timm #image-classification