本项目将 timm/tf_efficientnet_lite3.in1k 图像分类模型适配到昇腾 NPU (Ascend910)。
模型通过 ModelScope snapshot_download 下载权重,本地加载后运行于 npu:0,支持单图推理、CPU-NPU 精度一致性验证和性能基准测试。
pip install -r requirements.txt
python inference.py推理结果 (NPU):
=== NPU Inference ===
model: timm/tf_efficientnet_lite3.in1k
input_shape: [1, 3, 300, 300]
output_shape: [1, 1000]
NPU Top-5 Predictions:
Top-1: class_623 (0.008133)
Top-2: class_680 (0.006732)
Top-3: class_499 (0.006241)
Top-4: class_902 (0.006224)
Top-5: class_473 (0.006203)日志保存在 logs/inference.log。
对单张测试输入进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.003634 |
| mean_abs_error | 0.000834 |
| relative_error | 0.1525% |
| cosine_similarity | 0.999999 |
| threshold | 1.0% |
| 结果 | PASS |
CPU Top-1: class_623, NPU Top-1: class_623 (match: True)
CPU Top-5: class_623, class_680, class_499, class_902, class_473
NPU Top-5: class_623, class_680, class_499, class_902, class_473
Top-5 match: True
| 指标 | 数值 |
|---|---|
| avg_latency_ms | 10.283 |
| min_latency_ms | 9.483 |
| max_latency_ms | 11.475 |
| p50_latency_ms | 10.122 |
| p90_latency_ms | 11.289 |
| p95_latency_ms | 11.382 |
| throughput_ips | 97.24 |
测试配置: warmup 2, runs 10, device npu:0, input [1, 3, 300, 300]
本项目包含单输入 smoke consistency 验证,非官方完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png。
logs/inference.log — NPU 推理结果logs/accuracy.log — CPU-NPU 精度一致性logs/benchmark.log — 性能基准测试assets/test.jpg 为占位图(网络下载失败时生成的灰色图),仅用于 smoke test。#NPU