本项目将 timm/inception_v3.tf_adv_in1k 图片分类模型适配到昇腾 NPU (Ascend910)。
模型来源为 timm 库中的 InceptionV3,在 ImageNet-1k 上通过对抗训练 (adv) 获得权重。输入分辨率为 299x299,输出 1000 类分类 logits。
| 项目 | 版本/型号 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| PyTorch | 2.x |
| torch_npu | 适配 CANN 8.5.1 |
| timm | latest |
环境检查日志:logs/env_check.log
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.017452 |
| mean_abs_error | 0.003179 |
| relative_error | 0.3624% |
| cosine_similarity | 0.999995 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_latency_ms | 10.84 |
| min_latency_ms | 10.69 |
| max_latency_ms | 11.02 |
| p50_latency_ms | 10.83 |
| p90_latency_ms | 11.02 |
| p95_latency_ms | 11.02 |
| images_per_sec | 92.22 |
测试配置:batch=1, 输入 3x299x299, 预热 2 次 + 正式 10 次。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png。
logs/inference.log — NPU 推理输出logs/accuracy.log — CPU-NPU 精度一致性验证logs/benchmark.log — 性能基准测试logs/env_check.log — NPU 环境检查snapshot_download 下载,严禁使用 timm.create_model(..., pretrained=True) 从 HuggingFace 自动下载。timm.data.resolve_model_data_config 自动获取模型对应的预处理参数。.bin/.safetensors/.pth 等已加入 .gitignore)。#NPU #Ascend #Ascend910 #timm #InceptionV3 #image-classification