本项目将 timm/vit_srelpos_small_patch16_224.sw_in1k 图片分类模型适配到华为昇腾 NPU (Ascend910)。
timm.create_model(pretrained=False) + ModelScope 本地权重加载| 项目 | 版本/型号 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| PyTorch | 2.x |
| torch_npu | 可用 |
| timm | 最新版 |
环境详情见 logs/env_check.log。
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.017087 |
| mean_abs_error | 0.002245 |
| relative_error | 0.3843% |
| cosine_similarity | 0.999995 |
| threshold | 1.0% |
| 结果 | PASS |
在单卡 Ascend910 NPU 上运行 10 次取平均(Batch size = 1):
| 指标 | 数值 |
|---|---|
| Avg latency | 7.517 ms |
| Min latency | 7.458 ms |
| Max latency | 7.594 ms |
| P50 latency | 7.523 ms |
| P90 latency | 7.544 ms |
| P95 latency | 7.544 ms |
| Throughput (avg) | 133.03 images/sec |
| Throughput (min) | 131.68 images/sec |
| Throughput (max) | 134.09 images/sec |
日志保存在 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png 和 screenshots/self_verification.txt。
logs/env_check.log — 环境检查logs/inference.log — 推理输出logs/accuracy.log — CPU-NPU 精度一致性logs/benchmark.log — 性能基准测试snapshot_download 下载,严禁使用 timm.create_model(..., pretrained=True) 从 HuggingFace 自动下载。#NPU #Ascend #Ascend910 #timm #ViT #image-classification