Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
paddle_dbnet
Commits
09d36ac4
Unverified
Commit
09d36ac4
authored
May 18, 2020
by
Double_V
Committed by
GitHub
May 18, 2020
Browse files
Merge pull request #51 from LDOUBLEV/fixocr
fix inference md
parents
ce767d48
bfcc9381
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
3 deletions
+47
-3
README.md
README.md
+2
-0
doc/inference.md
doc/inference.md
+44
-1
tools/export_model.py
tools/export_model.py
+1
-2
No files found.
README.md
View file @
09d36ac4
...
@@ -47,6 +47,8 @@ python3 tools/infer/predict_system.py --image_dir="./doc/imgs/11.jpg" --det_mode
...
@@ -47,6 +47,8 @@ python3 tools/infer/predict_system.py --image_dir="./doc/imgs/11.jpg" --det_mode
```
```
更多的文本检测、识别串联推理使用方式请参考文档教程中
[
基于预测引擎推理
](
./doc/inference.md
)
。
更多的文本检测、识别串联推理使用方式请参考文档教程中
[
基于预测引擎推理
](
./doc/inference.md
)
。
## 文档教程
## 文档教程
-
[
快速安装
](
./doc/installation.md
)
-
[
快速安装
](
./doc/installation.md
)
-
[
文本检测模型训练/评估/预测
](
./doc/detection.md
)
(持续更新中)
-
[
文本检测模型训练/评估/预测
](
./doc/detection.md
)
(持续更新中)
...
...
doc/inference.md
View file @
09d36ac4
...
@@ -4,7 +4,50 @@
...
@@ -4,7 +4,50 @@
inference 模型(fluid.io.save_inference_model保存的模型)
inference 模型(fluid.io.save_inference_model保存的模型)
一般是模型训练完成后保存的固化模型,多用于预测部署。
一般是模型训练完成后保存的固化模型,多用于预测部署。
训练过程中保存的模型是checkpoints模型,保存的是模型的参数,多用于恢复训练等。
训练过程中保存的模型是checkpoints模型,保存的是模型的参数,多用于恢复训练等。
与checkpoints模型相比,inference 模型会额外保存模型的结构信息,在预测部署、加速推理上性能优越,灵活方便,适合与实际系统集成。更详细的介绍请参考文档
[
分类预测框架
](
https://paddleclas.readthedocs.io/zh_CN/latest/extension/paddle_inference.html
)
. 接下来将依次介绍文本检测、文本识别以及两者串联基于预测引擎推理。与此同时也会介绍checkpoints转换成inference model的实现。
与checkpoints模型相比,inference 模型会额外保存模型的结构信息,在预测部署、加速推理上性能优越,灵活方便,适合与实际系统集成。更详细的介绍请参考文档
[
分类预测框架
](
https://paddleclas.readthedocs.io/zh_CN/latest/extension/paddle_inference.html
)
.
接下来首先介绍如何将训练的模型转换成inference模型,然后将依次介绍文本检测、文本识别以及两者串联基于预测引擎推理。
## 训练模型转inference模型
### 检测模型转inference模型
下载超轻量级中文检测模型:
```
wget -P ./ch_lite/ https://paddleocr.bj.bcebos.com/ch_models/det_mv3_db.tar && tar xf ch_lite/det_mv3_db.tar -C ch_lite
```
上述模型是以MobileNetV3为backbone训练的DB算法,将训练好的模型转换成inference模型只需要运行如下命令:
```
python3 tools/export_model.py -c configs/det/det_mv3_db.yml -o Global.checkpoints=./ch_lite/det_mv3_db/best_accuracy Global.save_inference_dir=./inference_model/det_db/
```
转inference模型时,使用的配置文件和训练时使用的配置文件相同。另外,还需要设置配置文件中的Global.checkpoints、Global.save_inference_dir参数。
其中Global.checkpoints指向训练中保存的模型参数文件,Global.save_inference_dir是生成的inference模型要保存的目录。
转换成功后,在save_inference_dir 目录下有两个文件:
```
inference_model/det_db/
└─ model 检测inference模型的program文件
└─ params 检测inference模型的参数文件
```
### 识别模型转inference模型
下载超轻量中文识别模型:
```
wget -P ./ch_lite/ https://paddleocr.bj.bcebos.com/ch_models/rec_crnn.tar && tar xf ch_lite/rec_crnn.tar -C .ch_lite/
```
识别模型转inference模型与检测的方式相同,如下:
```
python3 tools/export_model.py -c configs/rec/rec_chinese_lite_train.yml -o Global.checkpoints=./ch_lite/rec_crnn/best_accuracy \
Global.save_inference_dir=./inference_model/rec_crnn/
```
如果您是在自己的数据集上训练的模型,并且调整了中文字符的字典文件,请注意修改配置文件中的character_dict_path是否是所需要的字典文件。
转换成功后,在目录下有两个文件:
```
/inference_model/rec_crnn/
└─ model 识别inference模型的program文件
└─ params 识别inference模型的参数文件
```
## 文本检测模型推理
## 文本检测模型推理
...
...
tools/export_model.py
View file @
09d36ac4
...
@@ -52,8 +52,7 @@ def main():
...
@@ -52,8 +52,7 @@ def main():
# check if set use_gpu=True in paddlepaddle cpu version
# check if set use_gpu=True in paddlepaddle cpu version
use_gpu
=
config
[
'Global'
][
'use_gpu'
]
use_gpu
=
config
[
'Global'
][
'use_gpu'
]
# program.check_gpu(True)
program
.
check_gpu
(
True
)
use_gpu
=
False
alg
=
config
[
'Global'
][
'algorithm'
]
alg
=
config
[
'Global'
][
'algorithm'
]
assert
alg
in
[
'EAST'
,
'DB'
,
'Rosetta'
,
'CRNN'
,
'STARNet'
,
'RARE'
]
assert
alg
in
[
'EAST'
,
'DB'
,
'Rosetta'
,
'CRNN'
,
'STARNet'
,
'RARE'
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment