本项目将 timm/edgenext_x_small.in1k 适配到华为昇腾 NPU (Ascend910) 上运行。该模型是 EdgeNeXt-X-Small 架构的图像分类模型,在 ImageNet-1k 上训练,参数量仅 2.34M,适合边缘部署场景。
| 项目 | 版本/型号 |
|---|---|
| NPU | Ascend910 (x2) |
| CANN | 8.5.1 |
| torch | 2.9.0+cpu |
| torch_npu | 2.9.0 |
| timm | 1.0.27 |
| Python | 3.11.14 |
环境检查日志: logs/env_check.log
pip install -r requirements.txt
python inference.py推理结果 (NPU):
Input shape: [1, 3, 256, 256]
Output shape: [1, 1000]
Output logits sample: [-0.2183, -0.7739, -0.9446, -0.3749, -1.3589]
Top-5 predictions:
1. class=813, prob=0.0157
2. class=499, prob=0.0107
3. class=902, prob=0.0102
4. class=623, prob=0.0095
5. class=574, prob=0.0092日志保存在 logs/inference.log。
对单张测试输入进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.013972 |
| mean_abs_error | 0.003613 |
| relative_error | 0.4415% |
| cosine_similarity | 0.999991 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| warmup_runs | 2 |
| benchmark_runs | 10 |
| avg_ms | 7.164 |
| min_ms | 7.105 |
| max_ms | 7.238 |
| p50_ms | 7.155 |
| p90_ms | 7.238 |
| p95_ms | 7.238 |
| throughput | 139.59 img/s |
日志保存在 logs/benchmark.log。
本项目包含单输入 smoke consistency 验证,非官方完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.txt 与 screenshots/self_verification.png。
logs/env_check.log - 环境检查logs/inference.log - 推理输出logs/accuracy.log - 精度一致性验证logs/benchmark.log - 性能基准测试snapshot_download 自动下载到本地缓存,运行时会自动复用已下载的权重。timm.create_model(..., pretrained=False) 创建后加载本地 safetensors 权重,避免 HuggingFace 自动下载。resolve_model_data_config + create_transform 进行标准化预处理。#NPU #Ascend #Ascend910 #timm #EdgeNeXt #ImageNet