本项目将 timm/tf_efficientnet_b1.in1k 图片分类模型适配到昇腾 NPU (Ascend910) 上运行。
模型基于 EfficientNet-B1 架构,在 ImageNet-1K 上训练。输入分辨率为 240x240,输出 1000 类分类 logits。
| 项目 | 版本/型号 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| PyTorch | 2.9.0+cpu |
| torch_npu | 2.9.0.post1 |
| timm | 1.0.27 |
| Python | 3.11.14 |
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.003854 |
| mean_abs_error | 0.000671 |
| relative_error | 0.1054% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_latency_ms | 10.96 |
| min_latency_ms | 10.71 |
| max_latency_ms | 11.26 |
| p50_latency_ms | 10.94 |
| p90_latency_ms | 11.26 |
| p95_latency_ms | 11.26 |
| images_per_sec | 91.28 |
日志保存在 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png。
| 文件 | 说明 |
|---|---|
logs/inference.log | NPU 推理输出 |
logs/accuracy.log | CPU-NPU 精度一致性检查 |
logs/benchmark.log | NPU 性能基准测试 |
logs/env_check.log | 环境检查 |
snapshot_download 下载,严禁使用 timm.create_model(..., pretrained=True) 从 HuggingFace 自动下载。timm.data.resolve_model_data_config 自动获取模型对应的数据预处理配置。本模型输入尺寸为 240x240。Warning: The /usr/local/Ascend/cann-8.5.1 owner does not match),属环境正常提示,不影响推理。#NPU #Ascend #Ascend910 #timm #EfficientNet #image-classification