本项目将 timm/vit_small_patch16_224.augreg_in21k_ft_in1k (ViT-Small/16, ImageNet-21k fine-tuned on ImageNet-1k) 适配至华为昇腾 NPU (Ascend910),使其可在单卡 NPU 上完成推理、精度验证和性能基准测试。
pip install -r requirements.txt
python inference.py推理结果 (NPU):
[1, 3, 224, 224][1, 1000]对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.009717 |
| mean_abs_error | 0.002355 |
| relative_error | 0.2454% |
| cosine_similarity | 0.999997 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| Device | Ascend910_9362 |
| Batch size | 1 |
| Runs | 10 |
| avg latency | 5.40 ms |
| min latency | 5.36 ms |
| max latency | 5.49 ms |
| p50 | 5.40 ms |
| p90 | 5.45 ms |
| p95 | 5.47 ms |
| Throughput | 185.09 images/sec |
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png。
logs/inference.log — 推理结果logs/accuracy.log — 精度一致性检查logs/benchmark.log — 性能基准测试logs/env_check.log — 环境检查ModelScope snapshot_download 下载权重,不使用 HuggingFace 直连timm.create_model(pretrained=False) 加载本地权重#NPU