本项目将 timm/resnet34.a1_in1k 图片分类模型适配到华为昇腾 NPU (Ascend910) 上运行。
timm.create_model(pretrained=False) + ModelScope 本地权重加载| 项目 | 版本/型号 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| PyTorch | 2.x |
| torch_npu | 适配 CANN 8.5.1 |
pip install -r requirements.txt
python inference.py推理结果 (NPU Top-5):
日志保存在 logs/inference.log。
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.008050 |
| mean_abs_error | 0.001613 |
| relative_error | 0.0175% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_latency_ms | 4.069 |
| min_latency_ms | 3.970 |
| max_latency_ms | 4.206 |
| p50_latency_ms | 4.044 |
| p90_latency_ms | 4.206 |
| p95_latency_ms | 4.206 |
| images_per_sec | 245.77 |
日志保存在 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 - 环境检查日志snapshot_download 下载,不使用 HuggingFace 自动下载。timm.create_model 必须设置 pretrained=False,再通过 load_state_dict 加载本地权重。torch.npu.synchronize() 确保 NPU 同步。#NPU #Ascend #Ascend910 #ImageClassification #timm