将 timm 图像分类模型 maxvit_tiny_rw_224.sw_in1k 适配到单卡昇腾 NPU (Ascend910)。通过 ModelScope 的 snapshot_download 功能下载权重,使用 timm.create_model(pretrained=False) 加载本地权重,无需直接连接 HuggingFace。
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.018421 |
| mean_abs_error | 0.002410 |
| relative_error | 0.4243% |
| cosine_similarity | 0.999993 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_latency | 20.02 ms |
| min_latency | 19.09 ms |
| max_latency | 20.73 ms |
| p50 | 19.97 ms |
| p90 | 20.68 ms |
| p95 | 20.70 ms |
| images_per_sec | 49.94 |
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png
logs/env_check.log - 环境检查logs/inference.log - 推理结果logs/accuracy.log - 精度验证logs/benchmark.log - 性能基准#NPU #Ascend #timm #image-classification #Ascend910