本项目将 timm/eva02_large_patch14_448.mim_m38m_ft_in22k_in1k(EVA-02 Large ViT,patch size 14,输入分辨率 448×448)适配到单卡昇腾 NPU(Ascend910)上运行。模型通过 ModelScope 下载本地权重,使用 timm.create_model(pretrained=False) 加载,支持真实 NPU 推理、CPU-NPU 精度一致性验证与性能基准测试。
| 组件 | 版本/型号 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| PyTorch | 2.9.0+cpu |
| torch_npu | 与 CANN 8.5.1 配套 |
| timm | 1.0.27 |
| ModelScope | 最新 |
环境详情见 logs/env_check.log。
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
输入 shape: [1, 3, 448, 448],输出 shape: [1, 1000]。权重加载 0 missing / 0 unexpected keys。
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.007395 |
| mean_abs_error | 0.001363 |
| relative_error | 0.2867% |
| cosine_similarity | 0.999997 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| Avg latency | 34.041 ms |
| Min latency | 32.959 ms |
| Max latency | 36.023 ms |
| P50 latency | 33.931 ms |
| P90 latency | 35.997 ms |
| P95 latency | 35.997 ms |
| Throughput | 29.38 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 — 精度一致性logs/benchmark.log — 性能基准logs/paths.txt — 模型路径记录timm.create_model(..., pretrained=True) 自动从 HuggingFace 下载;本项目通过 ModelScope snapshot_download 获取本地权重。.bin、.safetensors、.pth 等)不提交到 Git 仓库,已在 .gitignore 中排除。timm.data.resolve_model_data_config 自动解析。#NPU #Ascend #Ascend910 #timm #image-classification