本项目将 timm/regnety_008_tv.tv2_in1k 图像分类模型适配到单卡昇腾 NPU (Ascend910) 上运行。
模型类型:图像分类 (ImageNet-1k, 1000 classes) 架构:RegNetY-008 (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_008_tv.tv2_in1k
Input source: assets/test.jpg
Output shape: torch.Size([1, 1000])
Top-5 predictions:
1. class=576, prob=0.1773
2. class=682, prob=0.0633
3. class=698, prob=0.0423
4. class=624, prob=0.0343
5. class=517, prob=0.0260日志保存在 logs/inference.log。
对单张测试输入进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.005747 |
| mean_abs_error | 0.000760 |
| relative_error | 0.1406% |
| cosine_similarity | 0.999999 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_latency | 7.77 ms |
| min_latency | 7.33 ms |
| max_latency | 7.98 ms |
| p50_latency | 7.89 ms |
| p90_latency | 7.96 ms |
| p95_latency | 7.97 ms |
| throughput | 128.66 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