本项目将 timm/deit_base_distilled_patch16_224.fb_in1k (DeiT-Base distilled patch16 224, ImageNet-1k pretrained) 模型适配到昇腾 NPU (Ascend910),使其可在单卡 NPU 上正常推理。使用 ModelScope snapshot_download 下载权重,timm.create_model(pretrained=False) 加载本地权重,无 HuggingFace 自动下载。
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.034234 |
| mean_abs_error | 0.006939 |
| relative_error | 0.5664% |
| cosine_similarity | 0.999987 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| 平均延迟 | 5.33 ms |
| 最小延迟 | 5.28 ms |
| 最大延迟 | 5.39 ms |
| P50 | 5.31 ms |
| P90 | 5.39 ms |
| P95 | 5.39 ms |
| 吞吐量 | 187.54 images/sec |
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
截图保存在 screenshots/self_verification.png。
logs/inference.log:推理结果日志logs/accuracy.log:精度验证日志logs/benchmark.log:性能基准日志logs/env_check.log:环境检查日志pretrained=False + ModelScope 本地权重加载,避免 HuggingFace 自动下载#NPU #Ascend #Ascend910 #DeiT #ImageClassification #timm