本项目将 timm/levit_conv_128s.fb_dist_in1k 模型适配到昇腾 NPU (Ascend910) 上运行。该模型是 LeViT-Conv-128S,一种结合卷积与视觉 Transformer 的高效图片分类模型,采用知识蒸馏训练。
| 项目 | 版本/型号 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| PyTorch | 2.x |
| torch_npu | 适配 CANN 8.5.1 |
环境检查日志见 logs/env_check.log。
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.011529 |
| mean_abs_error | 0.002486 |
| relative_error | 0.2557% |
| cosine_similarity | 0.999998 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_time | 7.74 ms |
| min_time | 7.12 ms |
| max_time | 8.06 ms |
| p50_time | 7.98 ms |
| p90_time | 8.06 ms |
| p95_time | 8.06 ms |
| images_per_sec | 129.15 |
日志保存在 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png。
logs/env_check.log — 环境检查logs/inference.log — 推理输出logs/accuracy.log — 精度一致性验证logs/benchmark.log — 性能基准测试snapshot_download 下载,严禁使用 pretrained=True 自动从 HuggingFace 下载。timm.data.resolve_model_data_config 自动获取预处理配置。#NPU #Ascend #Ascend910 #image-classification