本项目将 timm/resnet50.bt_in1k 图片分类模型适配到华为昇腾 NPU (Ascend910) 上运行。模型通过 ModelScope 下载权重,使用 timm.create_model(pretrained=False) 加载本地权重,并在 NPU 上完成推理验证、CPU-NPU 精度一致性检查和性能基准测试。
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.005075 |
| mean_abs_error | 0.000940 |
| relative_error | 0.1099% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| latency_avg_ms | 6.814 |
| latency_min_ms | 5.872 |
| latency_max_ms | 7.297 |
| latency_p50_ms | 6.867 |
| latency_p90_ms | 6.928 |
| latency_p95_ms | 6.928 |
| images_per_sec | 146.76 |
日志保存在 logs/benchmark.log。
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.txt 和 screenshots/self_verification.png。
logs/inference.log - 推理输出logs/accuracy.log - 精度验证结果logs/benchmark.log - 性能基准测试logs/env_check.log - NPU 环境检查snapshot_download 自动下载到本地缓存目录timm.create_model(..., pretrained=True) 自动从 HuggingFace 下载npu:0#NPU #Ascend #Ascend910 #timm #resnet50 #image-classification