本项目将 timm/pit_s_224.in1k 图片分类模型适配到单卡昇腾 NPU (Ascend910) 上运行。使用 ModelScope 下载权重,timm 加载本地权重,支持推理验证、CPU-NPU 精度一致性检查和性能基准测试。
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.017613 |
| mean_abs_error | 0.001556 |
| relative_error | 0.4620% |
| cosine_similarity | 0.999994 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_latency_ms | 5.533 |
| min_latency_ms | 5.463 |
| max_latency_ms | 5.736 |
| p50_latency_ms | 5.522 |
| p90_latency_ms | 5.736 |
| p95_latency_ms | 5.736 |
| images_per_sec | 180.73 |
日志保存在 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png 和 screenshots/self_verification.txt。
logs/inference.log: 推理结果日志logs/accuracy.log: 精度一致性验证日志logs/benchmark.log: 性能基准测试日志logs/env_check.log: 环境检查日志logs/paths.txt: 模型下载路径记录timm.create_model(pretrained=False) 加载,权重通过 ModelScope snapshot_download 本地加载,严禁使用 HuggingFace 自动下载。npu:0 上执行。#NPU #Ascend #Ascend910 #timm #PiT #image-classification