本项目将 timm/mobilenetv4_conv_medium.e500_r224_in1k 图片分类模型适配到昇腾 NPU (Ascend910) 上运行。模型通过 ModelScope 下载权重,使用 timm.create_model(pretrained=False) 加载本地权重,并在 NPU 上完成推理验证、精度一致性检查和性能基准测试。
| 项目 | 版本/型号 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| PyTorch | 2.9.0+cpu |
| torch_npu | 2.9.0.post1 |
| timm | 1.0.27 |
| Python | 3.11.14 |
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.004597 |
| mean_abs_error | 0.000950 |
| relative_error | 0.0134% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg latency | 0.007896 s |
| min latency | 0.007845 s |
| max latency | 0.007942 s |
| p50 latency | 0.007886 s |
| p90 latency | 0.007942 s |
| p95 latency | 0.007942 s |
| Throughput | 126.64 images/sec |
日志保存在 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png。
logs/inference.log — NPU 推理输出logs/accuracy.log — CPU-NPU 精度一致性验证logs/benchmark.log — NPU 性能基准测试logs/env_check.log — 环境检查.safetensors、.bin、.pth 等)不包含在仓库中,首次运行时会通过 ModelScope 自动下载。npu:0 设备。#NPU #Ascend #Ascend910 #timm #MobileNetV4 #ImageClassification