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

timm/vit_small_patch16_224.augreg_in21k_ft_in1k on Ascend NPU

1. 简介

本项目将 timm/vit_small_patch16_224.augreg_in21k_ft_in1k (ViT-Small/16, ImageNet-21k fine-tuned on ImageNet-1k) 适配至华为昇腾 NPU (Ascend910),使其可在单卡 NPU 上完成推理、精度验证和性能基准测试。

2. 验证环境

  • 设备: Ascend910 (单卡)
  • 框架: PyTorch + torch_npu
  • Python: 3.x
  • 关键依赖: timm, modelscope, safetensors

3. 推理运行

pip install -r requirements.txt
python inference.py

推理结果 (NPU):

  • Input shape: [1, 3, 224, 224]
  • Output shape: [1, 1000]
  • Top-1: class_111 (0.0170)
  • Top-2: class_499 (0.0155)
  • Top-3: class_623 (0.0154)
  • Top-4: class_596 (0.0134)
  • Top-5: class_512 (0.0111)

4. 精度验证

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

指标数值
max_abs_error0.009717
mean_abs_error0.002355
relative_error0.2454%
cosine_similarity0.999997
threshold1.0%
结果PASS
  • CPU Top-1: class_111
  • NPU Top-1: class_111
  • CPU Top-5: class_111, class_499, class_623, class_596, class_512
  • NPU Top-5: class_111, class_499, class_623, class_596, class_512
  • Top-1 match: True
  • Top-5 match: True

5. 性能参考

指标数值
DeviceAscend910_9362
Batch size1
Runs10
avg latency5.40 ms
min latency5.36 ms
max latency5.49 ms
p505.40 ms
p905.45 ms
p955.47 ms
Throughput185.09 images/sec

6. 精度评测说明

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

7. 自验证截图

见 screenshots/self_verification.png。

8. 日志文件

  • logs/inference.log — 推理结果
  • logs/accuracy.log — 精度一致性检查
  • logs/benchmark.log — 性能基准测试
  • logs/env_check.log — 环境检查

9. 注意事项

  • 使用 ModelScope snapshot_download 下载权重,不使用 HuggingFace 直连
  • 使用 timm.create_model(pretrained=False) 加载本地权重
  • 不提交权重文件(*.bin, *.safetensors 等已排除)
  • 单图 smoke test,非完整精度评测

10. 标签

#NPU