g
gyccc/timm-swinv2_base_window12to16_192to256.ms_in22k_ft_in1k-NPU
模型介绍文件和版本Pull Requests讨论分析
下载使用量0

timm/swinv2_base_window12to16_192to256.ms_in22k_ft_in1k on Ascend NPU

1. 简介

将 ModelScope 上的 timm/swinv2_base_window12to16_192to256.ms_in22k_ft_in1k 图片分类模型适配到华为昇腾 NPU (Ascend910)。该模型为 Swin Transformer V2 Base 架构,输入分辨率 256×256,输出 1000 类 ImageNet 分类。使用 ModelScope snapshot_download 下载权重,timm.create_model(pretrained=False) 加载本地权重。

2. 验证环境

  • 硬件:华为昇腾 NPU (Ascend910)
  • OS:Linux 5.10.0
  • Python 3.11
  • PyTorch + torch_npu
  • timm
  • ModelScope

3. 推理运行

# 安装依赖
pip install -r requirements.txt

# 运行推理
python inference.py

推理脚本使用 npu:0 进行真实 NPU 推理,输出 Top-5 预测结果。

4. 精度验证

对单张测试图片进行 CPU 与 NPU 一致性验证:

指标数值
max_abs_error0.018901
mean_abs_error0.003905
relative_error0.4171%
cosine_similarity0.999992
threshold1.0%
结果PASS
  • CPU Top-1: class_674
  • NPU Top-1: class_674
  • CPU Top-5: class_674, class_749, class_549, class_584, class_314
  • NPU Top-5: class_674, class_749, class_549, class_584, class_314
  • Top-1 match: True
  • Top-5 match: True

5. 性能参考

指标数值
平均延迟35.063 ms
最小延迟22.437 ms
最大延迟56.141 ms
p5024.298 ms
p9056.141 ms
p9556.141 ms
吞吐量28.52 images/sec

6. 精度评测说明

本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。详细指标见第 4 节。

7. 自验证截图

详见 screenshots/self_verification.txt 和 screenshots/self_verification.png。

8. 日志文件

  • logs/inference.log — NPU 推理日志
  • logs/accuracy.log — CPU-NPU 精度一致性检查
  • logs/benchmark.log — NPU 性能基准测试

9. 注意事项

  • 该模型为 Swin Transformer V2 Base,输入分辨率 256×256(模型名中 192to256 表示从 192 分辨率 fine-tune 到 256)
  • 使用 timm.data.resolve_model_data_config 自动生成预处理
  • 所有权重通过 ModelScope snapshot_download 下载,未使用 HuggingFace 直连

10. 标签

#NPU