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

timm/efficientnet_el_pruned.in1k on Ascend NPU

1. 简介

将 timm EfficientNet-EL (pruned, ImageNet-1K pretrained) 适配到华为昇腾 NPU (Ascend910)。使用 ModelScope 下载权重,timm.create_model(pretrained=False) 加载本地权重,包含推理验证、CPU-NPU 精度一致性检查和性能基准测试。

  • 模型来源:ModelScope timm/efficientnet_el_pruned.in1k
  • 模型架构:EfficientNet-EL (pruned)
  • 参数量:~12M
  • 输入分辨率:300x300
  • 输出类别数:1000 (ImageNet-1K)

2. 验证环境

项目值
NPU华为昇腾 910 (Ascend910_9362)
PyTorch2.9.0+cpu
torch_npu2.9.0.post1+gitee7ba04
timm1.0.27
CANN8.5.1
驱动npu-smi 25.5.2

3. 推理运行

pip install -r requirements.txt
python inference.py

推理结果 (NPU Top-5):

  • Top-1: class_644 (0.0058)
  • Top-2: class_21 (0.0044)
  • Top-3: class_549 (0.0040)
  • Top-4: class_783 (0.0039)
  • Top-5: class_701 (0.0039)

日志保存在 logs/inference.log。

4. 精度验证

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

指标数值
max_abs_error0.004758
mean_abs_error0.000939
relative_error0.2319%
cosine_similarity0.999997
threshold1.0%
结果PASS
  • CPU Top-1: class_644
  • NPU Top-1: class_644
  • CPU Top-5: class_644, class_21, class_549, class_783, class_701
  • NPU Top-5: class_644, class_21, class_549, class_783, class_701
  • Top-1 match: True
  • Top-5 match: True

CPU-NPU 相对误差为 0.2319%,远低于 1.0% 阈值,精度一致性验证通过。

5. 性能参考

指标数值
设备npu:0 (Ascend910)
输入[1, 3, 300, 300]
测试次数10
平均延迟9.70 ms
最小延迟9.37 ms
最大延迟12.01 ms
P50 延迟9.44 ms
P90 延迟9.79 ms
P95 延迟10.90 ms
吞吐量103.10 images/sec

6. 精度评测说明

本项目包含单图 smoke consistency 验证,非官方 ImageNet 完整验证集评测。CPU-NPU 一致性检查在单张测试图片上对比 CPU 与 NPU 的推理输出,验证模型在 NPU 上的数值精度与 CPU 一致。详细指标见第 4 节。

7. 自验证截图

截图保存在 screenshots/self_verification.png,包含 NPU 环境、推理结果、精度验证和性能测试摘要。

8. 日志文件

  • logs/inference.log — 推理结果
  • logs/accuracy.log — 精度验证详细数据
  • logs/benchmark.log — 性能基准测试结果
  • logs/env_check.log — 环境检查信息

9. 注意事项

  • 本适配使用 ModelScope snapshot_download 下载权重,不使用 HuggingFace 自动下载
  • 模型使用 timm.create_model(pretrained=False) + 本地权重加载
  • 精度验证为单图 smoke test,非 ImageNet 完整验证集评测
  • CPU-NPU 精度相对误差 0.2319%,低于 1.0% 阈值,满足适配要求

10. 标签

#NPU #Ascend #Ascend910 #timm #EfficientNet #ImageClassification