volo_d1_384 是基于 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 | window screen | 78.05% |
| 2 | entertainment center | 5.05% |
| 3 | yurt | 2.72% |
| 4 | wig | 1.00% |
| 5 | slide rule | 0.20% |
CPU 推理耗时: 1.1489s
| 排名 | 类别 | 概率 |
|---|---|---|
| 1 | window screen | 77.83% |
| 2 | entertainment center | 5.03% |
| 3 | yurt | 2.74% |
| 4 | wig | 1.00% |
| 5 | slide rule | 0.20% |
NPU 推理耗时: 0.2133s
| 指标 | CPU | NPU |
|---|---|---|
| 推理耗时 (s) | 1.1489 | 0.2133 |
NPU 推理加速比: 5.39x
运行精度对比脚本:
python3 compare_cpu_npu.py| 指标 | 数值 |
|---|---|
| Logits 最大绝对误差 | 0.02060699 |
| Logits 平均绝对误差 | 0.00145573 |
| Logits 余弦相似度 | 0.99999666 |
| 概率最大差异 | 0.22% |
| 概率平均差异 | 4.87e-06 |
| Top-5 一致数 | 5/5 |
| Top-1 匹配 | True |
| 排名 | CPU 类别 | CPU 概率 | NPU 类别 | NPU 概率 | 匹配 |
|---|---|---|---|---|---|
| 1 | window screen | 78.05% | window screen | 77.83% | ✓ |
| 2 | entertainment center | 5.05% | entertainment center | 5.03% | ✓ |
| 3 | yurt | 2.72% | yurt | 2.74% | ✓ |
| 4 | wig | 1.00% | wig | 1.00% | ✓ |
| 5 | slide rule | 0.20% | slide rule | 0.20% | ✓ |
NPU 与 CPU 推理结果误差 < 1%。 具体数值:

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