本项目将 timm/tiny_vit_5m_224.in1k 模型适配到华为昇腾 NPU (Ascend910) 上运行。使用 ModelScope 下载权重,timm 加载模型,支持推理验证、CPU-NPU 精度一致性检查和性能基准测试。
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.009952 |
| mean_abs_error | 0.002449 |
| relative_error | 0.6064% |
| cosine_similarity | 0.999988 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| warmup_runs | 2 |
| benchmark_runs | 10 |
| avg_latency_ms | 8.562 |
| min_latency_ms | 8.527 |
| max_latency_ms | 8.657 |
| p50_latency_ms | 8.551 |
| p90_latency_ms | 8.657 |
| p95_latency_ms | 8.657 |
| images_per_sec | 116.79 |
日志保存在 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png 和 screenshots/self_verification.txt。
logs/inference.log — NPU 推理输出logs/accuracy.log — CPU-NPU 精度一致性检查结果logs/benchmark.log — NPU 性能基准测试结果logs/env_check.log — NPU 环境信息snapshot_download 下载,禁止 HuggingFace 自动下载。timm.create_model(..., pretrained=False) + 本地权重加载。#NPU #Ascend #Ascend910 #timm #image-classification