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

google/efficientnet-b7 on Ascend NPU

1. 简介

将 ModelScope 上的 google/efficientnet-b7 图片分类模型适配到华为昇腾 NPU (Ascend910B) 上运行。

  • 原始权重地址:https://modelscope.cn/models/google/efficientnet-b7
  • 模型架构:EfficientNetForImageClassification
  • 输入尺寸:600x600
  • 输出类别数:1000 (ImageNet-1K)

2. 验证环境

  • 硬件:华为昇腾 910B NPU
  • 操作系统:Linux (aarch64)
  • Python:3.11
  • PyTorch:2.x + torch_npu
  • CANN:8.5.1
  • transformers:4.57.6
  • ModelScope:latest

3. 推理运行

pip install -r requirements.txt
python inference.py

推理结果 (NPU Top-5):

  • Top-1: promontory, headland, head, foreland (0.3328)
  • Top-2: seashore, coast, seacoast, sea-coast (0.2831)
  • Top-3: cliff, drop, drop-off (0.0851)
  • Top-4: sandbar, sand bar (0.0379)
  • Top-5: valley, vale (0.0156)

日志保存在 logs/inference.log。

4. 精度验证

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

指标数值
max_abs_error0.001999
mean_abs_error0.000290
relative_error0.0566%
cosine_similarity1.000000
threshold1.0%
结果PASS
  • CPU Top-1: promontory, headland, head, foreland
  • NPU Top-1: promontory, headland, head, foreland
  • CPU Top-5: promontory, headland, head, foreland, seashore, coast, seacoast, sea-coast, cliff, drop, drop-off, sandbar, sand bar, valley, vale
  • NPU Top-5: promontory, headland, head, foreland, seashore, coast, seacoast, sea-coast, cliff, drop, drop-off, sandbar, sand bar, valley, vale
  • Top-1 match: True
  • Top-5 match: True

5. 性能参考

指标数值
Avg latencyms
Min latencyms
Max latencyms
P50 latencyms
P90 latencyms
P95 latencyms
Throughputimages/sec

测试条件:2 次预热 + 10 次正式测量,batch_size=1,单卡 NPU。

6. 精度评测说明

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

7. 自验证截图

自验证截图

8. 日志文件

  • logs/inference.log — NPU 推理结果
  • logs/accuracy.log — CPU-NPU 精度一致性验证
  • logs/benchmark.log — 性能基准测试

9. 注意事项

  • 使用 ModelScope snapshot_download 下载权重,禁止 HuggingFace 自动下载
  • 使用 EfficientNetForImageClassification.from_pretrained 加载预训练权重
  • 推理使用 torch.npu.synchronize() 确保 NPU 计算完成
  • 精度验证使用官方 Ascend 一致性指标:max_abs_error、mean_abs_error、relative_error、cosine_similarity

10. 标签 #NPU