w
gcw_uQ09W7jl/timm-convnext_base.clip_laion2b-NPU
模型介绍文件和版本Pull Requests讨论分析
下载使用量0

timm/convnext_base.clip_laion2b on Ascend NPU

1. 简介

本项目将 timm/convnext_base.clip_laion2b 适配到华为昇腾 NPU (Ascend910) 上运行。该模型是基于 ConvNeXt-Base 架构、使用 CLIP 在 LAION-2B 数据集上预训练的图像分类模型,通过 timm 加载,输出 640 维 logits。

  • 模型架构: ConvNeXt-Base
  • 参数量: ~88.22M
  • 输入尺寸: 3x256x256 (timm 自动解析)
  • 输出维度: 640-class logits
  • 权重格式: safetensors

2. 验证环境

项目版本/型号
NPUAscend910 (x2)
CANN8.5.1
torch2.9.0+cpu
torch_npu2.9.0
timm1.0.27
Python3.11.14

环境检查日志: logs/env_check.log

3. 推理运行

pip install -r requirements.txt
python inference.py

推理结果 (NPU):

Input shape: [1, 3, 256, 256]
Output shape: [1, 640]
Output logits sample: [-0.0874, -0.1260, -0.0281, 0.1408, -0.0665]

Top-5 predictions:
  1. class=493, prob=0.0091
  2. class=521, prob=0.0052
  3. class=320, prob=0.0046
  4. class=30, prob=0.0037
  5. class=505, prob=0.0036

日志保存在 logs/inference.log。

4. 精度验证

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

指标数值
max_abs_error0.013091
mean_abs_error0.001230
relative_error0.6091%
cosine_similarity0.999982
threshold1.0%
结果PASS

5. 性能参考

指标数值
warmup_runs2
benchmark_runs10
avg_ms14.857
min_ms14.832
max_ms14.876
p50_ms14.857
p90_ms14.876
p95_ms14.876
throughput67.31 img/s

日志保存在 logs/benchmark.log。

6. 精度评测说明

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

7. 自验证截图

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

8. 日志文件

  • logs/env_check.log - 环境检查
  • logs/inference.log - 推理输出
  • logs/accuracy.log - 精度一致性验证
  • logs/benchmark.log - 性能基准测试

9. 注意事项

  • 权重通过 ModelScope snapshot_download 自动下载到本地缓存,运行时会自动复用已下载的权重。
  • 模型使用 timm.create_model(..., pretrained=False) 创建后加载本地 safetensors 权重,避免 HuggingFace 自动下载。
  • 推理时输入经过 timm 的 resolve_model_data_config + create_transform 进行标准化预处理。
  • NPU 上存在 double dtype 自动 cast 为 float 的 warning,不影响最终精度。

10. 标签

#NPU #Ascend #Ascend910 #timm #ConvNeXt #CLIP