本项目将 timm/tf_efficientnet_b2.ns_jft_in1k 适配到昇腾 NPU (Ascend910) 上进行图片分类推理。
该模型为 EfficientNet-B2,在 JFT 上预训练后在 ImageNet-1k 上微调,输出 1000 个类别 logits。
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.002841 |
| mean_abs_error | 0.000537 |
| relative_error | 0.1239% |
| cosine_similarity | 0.999999 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| warmup_iterations | 2 |
| benchmark_iterations | 10 |
| avg_latency(s) | 0.009840 |
| min_latency(s) | 0.009778 |
| max_latency(s) | 0.010039 |
| p50_latency(s) | 0.009821 |
| p90_latency(s) | 0.009881 |
| p95_latency(s) | 0.009960 |
| images_per_sec | 101.63 |
日志保存在 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png。
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 下载。class_<index> 形式展示。torch.npu.synchronize() 确保时序正确。#NPU