cv_beitv2-large_image-classification_patch16_224_pt1k_ft22k_in1k - Ascend NPU 适配
1. 模型简介
BEiTv2 Large 图像分类模型,基于 Vision Transformer-Large 架构 (24层, 1024 hidden),在 ImageNet-1k 上微调。
2. 昇腾 NPU 适配结果
| 指标 | 值 |
|---|
| Cosine Similarity | 1.000000 |
| Max Abs Error | 0.000000 |
| 平均延迟 | 16.86ms |
| 输出维度 | (1, 1000) |
| 推理精度 | float32 |
| 设备 | Ascend 910B4 |
3. 环境要求
| 组件 | 版本 |
|---|
| CANN | 8.5.1 |
| torch_npu | 2.9.0.post1 |
| PyTorch | 2.9.0 |
| Python | 3.11 |
| timm | latest |
4. 快速使用
export ASCEND_HOME_PATH=/usr/local/Ascend/cann
export LD_LIBRARY_PATH=/usr/local/Ascend/cann/lib64:$LD_LIBRARY_PATH
python inference.py
python evaluate.py
5. 推理输出证据
Model: iic/cv_beitv2-large_image-classification_patch16_224_pt1k_ft22k_in1k
Device: npu:0
Output shape: [1, 1000]
Output sample: [-0.0008012278703972697, 0.0007319471333175898, 0.0005658459849655628, 0.001482490450143814, -0.000631795555818826]
Latency: 16.86ms
--- CPU vs NPU 精度对比 ---
Cosine Similarity: 1.000000
Max Abs Error: 0.000000
SUCCESS
6. CPU vs NPU 精度对比
| 指标 | CPU (float32) | NPU (float32) | 误差 |
|---|
| Cosine Similarity | 基准 | 1.000000 | 0 |
| Max Abs Error | - | 0.000000 | - |
| 输出维度 | (1, 1000) | (1, 1000) | 一致 |
7. 模型结构
- Backbone: BEiTv2-Large (24 layers)
- Hidden Size: 1024
- Attention Heads: 16
- Patch Size: 16
- Image Size: 224
- Num Classes: 1000