本项目将 timm/convnext_base.fb_in1k 图片分类模型适配到华为昇腾 NPU(Ascend910B),使其能够在单卡 NPU 上完成推理、精度验证和性能测试。
cd timm-convnext_base.fb_in1k-NPU
python inference.py推理输出 [1, 1000] logits,Top-5 预测:
NPU 推理成功,详见 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.008154 |
| mean_abs_error | 0.001441 |
| relative_error | 0.4494% |
| cosine_similarity | 0.999996 |
| threshold | 1.0% |
| 结果 | PASS |
详见 logs/accuracy.log。
| 指标 | 数值 |
|---|---|
| avg_latency_ms | 19.397 |
| min_latency_ms | 14.843 |
| max_latency_ms | 46.750 |
| p50_latency_ms | 14.910 |
| p90_latency_ms | 46.750 |
| p95_latency_ms | 46.750 |
| images_per_sec | 51.55 |
测试条件:预热 2 次 + 正式 10 次,batch=1,输入 224x224。详见 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png。
logs/inference.log - 推理日志logs/accuracy.log - 精度验证日志logs/benchmark.log - 性能基准日志timm.create_model(pretrained=False) 创建结构,手动加载本地权重#NPU