本项目将 timm/deit_base_distilled_patch16_224.fb_in1k 模型适配到华为昇腾 NPU (Ascend910)。
timm.create_model(pretrained=False) + ModelScope snapshot_download 本地权重加载| 组件 | 版本 |
|---|---|
| CANN | 8.5.1 |
| PyTorch | 2.x |
| torch_npu | 适配 CANN 8.5.1 |
| timm | 1.0.27 |
| Python | 3.11 |
| NPU | Ascend910 |
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.072346 |
| mean_abs_error | 0.009754 |
| relative_error | 0.9540% |
| cosine_similarity | 0.999963 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| warmup_iterations | 2 |
| benchmark_iterations | 10 |
| avg_latency_ms | 5.387 |
| min_latency_ms | 5.312 |
| max_latency_ms | 5.521 |
| p50_latency_ms | 5.374 |
| p90_latency_ms | 5.521 |
| p95_latency_ms | 5.521 |
| images_per_sec | 185.65 |
日志保存在 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png。
| 日志 | 说明 |
|---|---|
logs/inference.log | NPU 推理输出及 Top-5 结果 |
logs/accuracy.log | CPU-NPU 精度一致性验证 |
logs/benchmark.log | NPU 性能基准测试 |
logs/env_check.log | NPU 环境检查 |
logs/paths.txt | 模型下载路径记录 |
snapshot_download 下载,首次运行需要联网。timm.create_model(..., pretrained=True) 从 HuggingFace 下载,必须使用本地权重加载。npu:0。#NPU #Ascend #Ascend910 #ImageClassification #DeiT #timm