waylong/timm-convnext_large.fb_in22k_ft_in1k-NPU
模型介绍文件和版本Pull Requests讨论分析
下载使用量0

timm/convnext_large.fb_in22k_ft_in1k on Ascend NPU

1. 简介

本项目将 timm/convnext_large.fb_in22k_ft_in1k 图片分类模型适配到单卡昇腾 NPU(Ascend910)上运行。

模型来源:ModelScope - timm/convnext_large.fb_in22k_ft_in1k

适配方式:使用 ModelScope snapshot_download 下载本地权重,通过 timm.create_model(pretrained=False) 创建模型并加载本地权重,确保在 NPU 上完成真实推理、精度一致性验证与性能基准测试。

2. 验证环境

项目版本/信息
NPUAscend910
CANN8.5.1
Python3.11.14
PyTorch2.x
torch_npu适配 CANN 8.5.1
timmlatest
modelscopelatest

NPU 状态:npu_available=True, device=Ascend910_9362

3. 推理运行

pip install -r requirements.txt
python inference.py

推理结果 (NPU Top-5):

  • Top-1: class_972 (0.7756)
  • Top-2: class_979 (0.0850)
  • Top-3: class_970 (0.0387)
  • Top-4: class_483 (0.0121)
  • Top-5: class_980 (0.0030)

日志保存在 logs/inference.log。

4. 精度验证

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

指标数值
max_abs_error0.042462
mean_abs_error0.005349
relative_error0.9049%
cosine_similarity0.999970
threshold1.0%
结果PASS
  • CPU Top-1: class_972
  • NPU Top-1: class_972
  • CPU Top-5: class_972, class_979, class_970, class_483, class_980
  • NPU Top-5: class_972, class_979, class_970, class_483, class_980
  • Top-1 match: True
  • Top-5 match: True

5. 性能参考

在单卡 Ascend910 NPU 上的性能基准(输入 [1, 3, 224, 224]):

指标数值
avg_time20.307 ms
min_time20.270 ms
max_time20.338 ms
p50_time20.310 ms
p90_time20.338 ms
p95_time20.338 ms
images_per_sec49.24

日志保存在 logs/benchmark.log。

6. 精度评测说明

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

7. 自验证截图

见 screenshots/self_verification.png 与 screenshots/self_verification.txt。

8. 日志文件

日志说明
logs/inference.logNPU 推理结果
logs/accuracy.logCPU-NPU 精度一致性
logs/benchmark.logNPU 性能基准
logs/env_check.logNPU 环境检查
logs/paths.txt模型路径记录

9. 注意事项

  1. 权重通过 ModelScope 下载,推理时 pretrained=False + 本地权重加载,不触发 HuggingFace 自动下载。
  2. 首次运行会自动下载模型权重(约 755MB),请确保网络畅通。
  3. 测试图片为随机下载的 400x300 图片,仅用于 smoke test,不代表真实 ImageNet 类别分布。
  4. 本项目不包含模型权重文件(*.bin / *.safetensors / *.pth 等已加入 .gitignore)。

10. 标签

#NPU #Ascend #Ascend910 #ConvNeXt #timm #image-classification