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

timm/tf_efficientnetv2_m.in21k_ft_in1k on Ascend NPU

1. 简介

本项目将 timm/tf_efficientnetv2_m.in21k_ft_in1k 图像分类模型适配到华为昇腾 NPU (Ascend910)。

模型基于 PyTorch 实现,通过 timm 库加载,使用 ModelScope snapshot_download 下载权重并本地加载,支持在单卡 NPU 上完成推理、精度一致性验证和性能基准测试。

2. 验证环境

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

详细环境信息见 logs/env_check.log。

3. 推理运行

pip install -r requirements.txt
python inference.py

推理结果 (NPU):

=== NPU Inference Result ===
Model: timm/tf_efficientnetv2_m.in21k_ft_in1k
Input shape: [1, 3, 384, 384]
Output shape: [1, 1000]
Output dtype: torch.float32

Top-5 predictions:
  1. class_idx=979, prob=0.865997
  2. class_idx=980, prob=0.029974
  3. class_idx=975, prob=0.007894
  4. class_idx=972, prob=0.003608
  5. class_idx=973, prob=0.003454

Raw logits (first 10):
  [0.37995484471321106, -0.15465034544467926, -0.9324793219566345, -0.023927170783281326, -0.7763705253601074, 1.3367199897766113, -0.07686387747526169, -1.1545323133468628, -0.6389279365539551, 0.6060746312141418]

日志保存在 logs/inference.log。

4. 精度验证

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

指标数值
max_abs_error0.001379
mean_abs_error0.000320
relative_error0.0472%
cosine_similarity1.000000
threshold1.0%
结果PASS

5. 性能参考

指标数值
Devicenpu:0
Input shape[1, 3, 384, 384]
avg latency22.347 ms
min latency21.799 ms
max latency22.919 ms
p50 latency22.271 ms
p90 latency22.911 ms
p95 latency22.915 ms
throughput44.75 samples/sec

6. 精度评测说明

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

7. 自验证截图

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

8. 日志文件

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

9. 注意事项

  • 权重通过 ModelScope snapshot_download 下载,首次运行会自动缓存到本地
  • 推理脚本默认使用 npu:0,如需更改请修改 inference.py 中的 .to("npu:0")
  • 测试图片下载自 https://picsum.photos/400/300,如无法访问会生成占位图

10. 标签

#NPU #Ascend #Ascend910 #timm #EfficientNetV2