将 timm 库中的 VGG19 图像分类模型适配到华为昇腾 NPU (Ascend910) 上运行。使用 ModelScope snapshot_download 下载权重,timm.create_model(pretrained=False) 创建模型结构并加载本地权重,无需 HuggingFace 直连下载。
pip install -r requirements.txt
python inference.py推理结果(Top-5):
对单张测试图片进行 CPU 与 NPU 一致性验证:
| 指标 | 数值 |
|---|---|
| max_abs_error | 0.003692 |
| mean_abs_error | 0.000917 |
| relative_error | 0.0435% |
| cosine_similarity | 1.000000 |
| threshold | 1.0% |
| 结果 | PASS |
| 指标 | 数值 |
|---|---|
| avg_latency | 3.06 ms |
| min_latency | 3.05 ms |
| max_latency | 3.08 ms |
| p50_latency | 3.06 ms |
| p90_latency | 3.07 ms |
| p95_latency | 3.08 ms |
| throughput | 326.55 images/sec |
本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。
见 screenshots/self_verification.png
logs/inference.log - 推理结果logs/accuracy.log - 精度验证结果logs/benchmark.log - 性能基准结果logs/env_check.log - NPU 环境信息#NPU #Ascend #Ascend910 #VGG19 #ImageClassification #timm