将 timm 框架下的 DeiT3 Base 模型 (deit3_base_patch16_224.fb_in1k) 适配到华为昇腾 NPU (Ascend910B)。使用 ModelScope snapshot_download 下载权重,timm.create_model(pretrained=False) 创建结构并加载本地权重,无需 HuggingFace 直连。
python inference.py输出示例(随机测试图片):
Top-5 predictions:
1. class_0460 (39.27%)
2. class_0565 (9.91%)
3. class_0547 (9.18%)
4. class_0920 (7.36%)
5. class_0525 (6.07%)对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.100382 |
| mean_abs_error | 0.058626 |
| relative_error | 0.7739% |
| cosine_similarity | 0.999998 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_latency | 8.69 ms |
| min_latency | 5.58 ms |
| max_latency | 35.68 ms |
| p50_latency | 5.69 ms |
| p90_latency | 8.84 ms |
| p95_latency | 22.26 ms |
| throughput | 115.07 images/sec |
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
详见 screenshots/self_verification.png。
logs/inference.log — 推理输出日志logs/accuracy.log — CPU-NPU 精度一致性检查日志logs/benchmark.log — 性能基准测试日志timm.create_model(pretrained=False) + ModelScope 本地权重,不使用 HuggingFace 直连下载#NPU