本项目将 timm/convformer_s18.sail_in22k 图片分类模型适配到华为昇腾 NPU(Ascend910)。
使用 ModelScope 下载权重,通过 timm.create_model(..., pretrained=False) 加载本地权重,
并在 NPU 上完成推理验证、CPU-NPU 精度一致性检查和性能基准测试。
环境详情见 logs/env_check.log。
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.000631 |
| mean_abs_error | 0.000120 |
| relative_error | 0.0064% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
在单卡 Ascend910 上,输入尺寸 (1, 3, 224, 224) 的基准测试结果:
| 指标 | 数值 |
|---|---|
| avg_latency_ms | 12.53 |
| min_latency_ms | 12.33 |
| max_latency_ms | 12.72 |
| p50_latency_ms | 12.54 |
| p90_latency_ms | 12.72 |
| p95_latency_ms | 12.72 |
| images_per_sec | 79.82 |
日志保存在 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png。
logs/env_check.log — 环境检查日志logs/inference.log — 推理日志logs/accuracy.log — 精度验证日志logs/benchmark.log — 性能基准测试日志snapshot_download 自动下载,首次运行需联网。timm.create_model(..., pretrained=True),避免 HuggingFace 自动下载。#NPU #Ascend #Ascend910 #timm #convformer #image-classification