本项目将 timm/wide_resnet50_2.tv_in1k 图片分类模型适配到昇腾 NPU (Ascend910) 上运行。
timm.create_model(pretrained=False) 创建模型结构,通过 ModelScope snapshot_download 下载本地权重并加载,确保真实 NPU 推理。| 项目 | 版本/型号 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| PyTorch | 2.x |
| torch_npu | 适配 CANN 8.5.1 |
| timm | latest |
环境检查日志: logs/env_check.log
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.001165 |
| mean_abs_error | 0.000256 |
| relative_error | 0.0204% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_latency_ms | 6.613 |
| min_latency_ms | 6.522 |
| max_latency_ms | 6.967 |
| p50_latency_ms | 6.568 |
| p90_latency_ms | 6.967 |
| images_per_sec | 151.21 |
测试条件:单卡 Ascend910,batch_size=1,预热 2 轮,正式测试 10 轮。
本项目包含单图 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 | NPU 性能基准测试 |
timm.create_model(..., pretrained=False) 禁止自动从 HuggingFace 下载权重。#NPU #Ascend #Ascend910 #timm #image-classification