本项目将 timm/tf_efficientnet_b7.ns_jft_in1k 图片分类模型适配到昇腾 NPU (Ascend910) 上运行。
使用 ModelScope snapshot_download 下载本地权重,timm.create_model(pretrained=False) 加载模型,
包含推理验证、CPU-NPU 精度一致性检查和性能基准测试。
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.000224 |
| mean_abs_error | 0.000052 |
| relative_error | 0.0917% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| iterations | 10 |
| avg_latency(s) | 0.032177 |
| min_latency(s) | 0.032149 |
| max_latency(s) | 0.032226 |
| p50_latency(s) | 0.032175 |
| p90_latency(s) | 0.032199 |
| p95_latency(s) | 0.032213 |
| images_per_sec | 31.08 |
日志保存在 logs/benchmark.log。
本项目包含单图 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 环境检查pretrained=False 并通过 ModelScope 下载本地权重加载,严禁使用 HuggingFace 自动下载。#NPU #Ascend #Ascend910 #timm #EfficientNet