本项目将 timm/deit_small_patch16_224.fb_in1k 图片分类模型适配到华为昇腾 NPU(Ascend910)上运行。
安装依赖:
pip install -r requirements.txtpython inference.py推理结果示例(单张测试图片):
| Rank | Class | Probability |
|---|---|---|
| 1 | class_698 | 0.3404 |
| 2 | class_743 | 0.0780 |
| 3 | class_829 | 0.0456 |
| 4 | class_576 | 0.0386 |
| 5 | class_442 | 0.0232 |
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.019989 |
| mean_abs_error | 0.004128 |
| relative_error | 0.4931% |
| cosine_similarity | 0.999990 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| Warmup | 2 |
| Runs | 10 |
| avg latency | 16.165 ms |
| min latency | 12.846 ms |
| max latency | 25.047 ms |
| p50 latency | 15.456 ms |
| p90 latency | 25.047 ms |
| p95 latency | 25.047 ms |
| Throughput | 61.86 images/sec |
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png
logs/inference.log — 推理结果logs/accuracy.log — CPU-NPU 精度一致性logs/benchmark.log — 性能基准测试| 项目 | 链接 |
|---|---|
| 原始权重模型地址 | https://modelscope.cn/models/timm/deit_small_patch16_224.fb_in1k |
| 提交项目地址 | https://ai.gitcode.com/v50_/timm-deit_small_patch16_224.fb_in1k-NPU |
提交说明:适配 timm/deit_small_patch16_224.fb_in1k 到昇腾 NPU (Ascend910)。使用 ModelScope snapshot_download 下载权重,timm.create_model(pretrained=False) 加载本地权重,包含推理验证、CPU-NPU 精度一致性检查和性能基准测试。
pretrained=False 并通过 load_state_dict 加载本地权重#NPU #Ascend #Ascend910 #ImageClassification #timm