13 Star 62 Fork 280

Ascend/ModelZoo-TensorFlow

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

中文|English

CRNN Tensorflow离线推理

此链接提供CRNN TensorFlow模型在NPU上离线推理的脚本和方法。原始训练模型请点击此链接: CRNN_for_Tensorflow

注意

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

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

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

快速指南

1. 拷贝代码

git clone https://gitee.com/ascend/ModelZoo-TensorFlow.git
cd ModelZoo-TensorFlow/tree/master/ACL_TensorFlow/built-in/cv/CRNN_for_ACL

2. 下载数据集和预处理

1.请自行下载IIIT5K/ICDAR03/SVT测试数据集,并将其放在 scripts/data/

2.测试数据集和标签的预处理

cd scripts
python3 tools/preprocess.py

将会生成 img_binlabels 目录:

img_bin
|___batch_data_000.bin
|___bathc_data_001.bin
...

labels
|___batch_label_000.txt
|___batch_label_001.txt
...

3. 离线推理

ckpt冻结ob

请使用训练脚本中的frozen_graph.py: [https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/built-in/cv/detection/CRNN_for_TensorFlow/tools/frozen_graph.py)

python3 frozen_graph.py --ckpt_path= ckpt_path/shadownet_xxx.ckpt-600000

离线模型转换

pb模型下载链接

  • 环境变量设置

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

  • Pb模型转换为om模型

    atc --model=shadownet_tf_64batch.pb --framework=3 --output=shadownet_tf_64batch --output_type=FP32 --soc_version=Ascend310 --input_shape="test_images:64,32,100,3" --log=info
    
  • 编译程序

    bash build.sh
    

    benchmark 工具的运行结果将会生成在 Benchmark/output/ 路径下

  • 开始运行:

    cd scripts
    bash benchmark_tf.sh
    

性能

结果

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

推理精度结果:

Test Dataset Per_Char_Accuracy Full_Seq_Accuracy
SVT 88.9% 77.2%
ICDAR2013 93.5% 87.3%
IIIT5K 91.4% 79.6%

参考

[1] https://gitee.com/ascend/ModelZoo-TensorFlow/tree/master/TensorFlow/built-in/cv/detection/CRNN_for_TensorFlow

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ascend/ModelZoo-TensorFlow.git
git@gitee.com:ascend/ModelZoo-TensorFlow.git
ascend
ModelZoo-TensorFlow
ModelZoo-TensorFlow
master

搜索帮助