本项目将 timm/regnety_320.swag_ft_in1k 图像分类模型适配到单卡昇腾 NPU (Ascend910) 上运行。
模型类型:图像分类 (ImageNet-1k, 1000 classes) 架构:RegNetY-320 (by timm)
| 项目 | 版本 |
|---|---|
| NPU | Ascend910 |
| CANN | 8.5.1 |
| PyTorch | 2.9.0+cpu |
| torch_npu | 与 CANN 8.5.1 配套 |
| timm | latest |
环境检查日志:logs/env_check.log
pip install -r requirements.txt
python inference.py推理结果 (NPU):
Model: timm/regnety_320.swag_ft_in1k
Input source: assets/test.jpg
Output shape: torch.Size([1, 1000])
Top-5 predictions:
1. class=499, prob=0.0198
2. class=623, prob=0.0167
3. class=696, prob=0.0163
4. class=650, prob=0.0142
5. class=596, prob=0.0117日志保存在 logs/inference.log。
对单张测试输入进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.002649 |
| mean_abs_error | 0.000665 |
| relative_error | 0.0835% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_latency | 17.85 ms |
| min_latency | 17.22 ms |
| max_latency | 18.59 ms |
| p50_latency | 17.77 ms |
| p90_latency | 18.52 ms |
| p95_latency | 18.56 ms |
| throughput | 56.01 samples/s |
注:性能数据在单卡 Ascend910 上测得,实际数值可能因负载、温度、驱动版本而波动。
本项目包含单输入 smoke consistency 验证,非官方完整验证集评测。详细指标见第 4 节。
screenshots/self_verification.txtscreenshots/self_verification.png| 文件 | 说明 |
|---|---|
logs/env_check.log | NPU 环境检查 |
logs/inference.log | NPU 推理输出 |
logs/accuracy.log | CPU-NPU 精度一致性 |
logs/benchmark.log | NPU 性能基准测试 |
ModelScope snapshot_download 自动下载到本地缓存,首次运行需要联网。pretrained=False + 本地 safetensors 权重加载,不依赖 HuggingFace 自动下载。#NPU #Ascend #Ascend910 #ImageClassification #timm