volo_d5_512 是基于 VOLO (Vision Outlooker) 架构的图像分类模型,在 ImageNet-1K 数据集上预训练。VOLO 通过引入 Outlooker 注意力机制,有效提升了视觉 Transformer 在细粒度分类任务上的性能。
图像分类 (Image Classification)
torch>=2.0.0
torch-npu>=2.1.0
timm>=0.9.0
Pillow>=9.0.0
scipy>=1.7.0
numpy>=1.20.0本模型已在华为昇腾 Ascend 910 NPU 上完成适配和测试。适配基于 PyTorch + torch_npu 框架,利用 timm 模型库加载预训练权重,通过 model.to("npu") 将模型迁移至 NPU 进行推理。
主要适配步骤:
model.to(torch.npu.current_device()))resolve_data_config + create_transform)# 设置 huggingface 镜像(如果无法访问 huggingface.co)
export HF_ENDPOINT=https://hf-mirror.com
# 安装依赖
pip install -r requirements.txtpython3 inference.py --device cpu --output cpu_result.jsonpython3 inference.py --device npu --output npu_result.json| 排名 | 类别 | 概率 |
|---|---|---|
| 1 | yurt | 86.24% |
| 2 | window screen | 4.00% |
| 3 | entertainment center | 1.77% |
| 4 | amphibian | 0.92% |
| 5 | teddy | 0.88% |
CPU 推理耗时: 17.1443s
| 排名 | 类别 | 概率 |
|---|---|---|
| 1 | yurt | 85.97% |
| 2 | window screen | 4.12% |
| 3 | entertainment center | 1.80% |
| 4 | teddy | 0.91% |
| 5 | amphibian | 0.89% |
NPU 推理耗时: 0.0799s
| 指标 | CPU | NPU |
|---|---|---|
| 推理耗时 (s) | 17.1443 | 0.0799 |
NPU 推理加速比: 214.57x
运行精度对比脚本:
python3 compare_cpu_npu.py| 指标 | 数值 |
|---|---|
| Logits 最大绝对误差 | 0.05673409 |
| Logits 平均绝对误差 | 0.00225027 |
| Logits 余弦相似度 | 0.99998361 |
| 概率最大差异 | 0.2657% |
| 概率平均差异 | 6.06e-06 |
| Top-5 一致数 | 5/5 |
| Top-1 匹配 | True |
| 排名 | CPU 类别 | CPU 概率 | NPU 类别 | NPU 概率 | 匹配 |
|---|---|---|---|---|---|
| 1 | yurt | 86.24% | yurt | 85.97% | ✓ |
| 2 | window screen | 4.00% | window screen | 4.12% | ✓ |
| 3 | entertainment center | 1.77% | entertainment center | 1.80% | ✓ |
| 4 | amphibian | 0.92% | teddy | 0.91% | ✗ |
| 5 | teddy | 0.88% | amphibian | 0.89% | ✗ |
NPU 与 CPU 推理结果误差 < 1%。 具体数值:

本模型适用于图像分类任务,可直接在华为昇腾 NPU 上部署推理:
对于批量推理需求,可将多个图像依次送入模型,并收集分类结果。