13 Star 61 Fork 279

Ascend/ModelZoo-TensorFlow

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

中文|English

MobileNetv2 TensorFlow离线推理

此链接提供MobileNetv2 TensorFlow模型在NPU上离线推理的脚本和方法

注意

此案例仅为您学习Ascend软件栈提供参考,不用于商业目的。

在开始之前,请注意以下适配条件。如果不匹配,可能导致运行失败。

Conditions Need
CANN版本 >=5.0.3
芯片平台 Ascend310/Ascend310P3
第三方依赖 请参考 'requirements.txt'

快速指南

1. 拷贝代码

git clone https://gitee.com/ascend/ModelZoo-TensorFlow.git
cd Modelzoo-TensorFlow/ACL_TensorFlow/built-in/cv/MobileNetv2_for_ACL

2. Download and preprocess the dataset

  1. 请自行下载ImageNet2012测试数据集

3. 离线推理

Pb模型转换为om模型

pb模型下载链接

  • 环境变量设置

    请参考说明,设置环境变量

  • Pb模型转换为om模型

    For Ascend310:

    atc --model=mobilenet_v2_tf.pb --framework=3 --output=mobilenet_v2_tf_aipp --output_type=FP32 --soc_version=Ascend310 --input_shape="input:1,224,224,3" --log=info --insert_op_conf=mobilenet_v2_tf_aipp.cfg
    

    For Ascend310P3:

    atc --model=mobilenet_v2_tf.pb --framework=3 --output=mobilenet_v2_tf_aipp --output_type=FP32 --soc_version=Ascend310P3 --input_shape="input:1,224,224,3" --log=info --insert_op_conf=mobilenet_v2_tf_aipp.cfg
    
  • 编译程序

    For Ascend310:

    unset ASCEND310P3_DVPP
    bash build.sh
    

    For Ascend310P3:

    export ASCEND310P3_DVPP=1
    bash build.sh
    
  • 开始运行:

    cd scripts
    bash benchmark_tf.sh --batchSize=1 --modelType=mobilenetv2 --imgType=raw --precision=fp16 --outputType=fp32 --useDvpp=1 --deviceId=0 --modelPath=mobilenet_v2_tf_aipp.om --dataPath=image-1024 --trueValuePath=val_lable.txt
    

性能

结果

本结果是通过运行上面适配的推理脚本获得的。要获得相同的结果,请按照《快速指南》中的步骤操作。

推理精度结果

model SOC data Top1/Top5
offline Inference Ascend310 50K images 71.75 %/ 90.48%
offline Inference Ascend310P3 50K images 72.2 %/ 90.8%
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ascend/ModelZoo-TensorFlow.git
git@gitee.com:ascend/ModelZoo-TensorFlow.git
ascend
ModelZoo-TensorFlow
ModelZoo-TensorFlow
master

搜索帮助