本项目将 timm/edgenext_base.usi_in1k 图片分类模型适配到昇腾 NPU (Ascend910) 上运行。
timm.create_model(pretrained=False) + ModelScope 本地权重加载| 项目 | 版本/信息 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| torch | PyTorch (with torch_npu) |
| 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.009187 |
| mean_abs_error | 0.002032 |
| relative_error | 0.3439% |
| cosine_similarity | 0.999994 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_latency_ms | 11.84 |
| min_latency_ms | 9.51 |
| max_latency_ms | 12.60 |
| p50_latency_ms | 12.09 |
| p90_latency_ms | 12.60 |
| p95_latency_ms | 12.60 |
| images_per_sec | 84.48 |
测试配置:batch_size=1, 预热 2 次, 正式 10 次, 单卡 Ascend910
日志保存在 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png 和 screenshots/self_verification.txt。
| 文件 | 内容 |
|---|---|
logs/env_check.log | NPU 环境检查 |
logs/inference.log | NPU 推理结果 |
logs/accuracy.log | CPU-NPU 精度一致性 |
logs/benchmark.log | 性能基准测试 |
snapshot_download 下载,严禁使用 timm.create_model(..., pretrained=True) 自动从 HuggingFace 下载。timm.data.resolve_model_data_config + create_transform 进行预处理。torch.npu.synchronize() 确保时序正确。#NPU #Ascend #Ascend910 #timm #EdgeNeXt #ImageClassification