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
b91055ee
Commit
b91055ee
authored
Dec 15, 2020
by
weishengyu
Browse files
rename style_text_rec -> style_text
parent
703bb1a9
Changes
40
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
23 additions
and
21 deletions
+23
-21
StyleText/README.md
StyleText/README.md
+0
-0
StyleText/README_ch.md
StyleText/README_ch.md
+23
-21
StyleText/__init__.py
StyleText/__init__.py
+0
-0
StyleText/arch/__init__.py
StyleText/arch/__init__.py
+0
-0
StyleText/arch/base_module.py
StyleText/arch/base_module.py
+0
-0
StyleText/arch/decoder.py
StyleText/arch/decoder.py
+0
-0
StyleText/arch/encoder.py
StyleText/arch/encoder.py
+0
-0
StyleText/arch/spectral_norm.py
StyleText/arch/spectral_norm.py
+0
-0
StyleText/arch/style_text_rec.py
StyleText/arch/style_text_rec.py
+0
-0
StyleText/configs/config.yml
StyleText/configs/config.yml
+0
-0
StyleText/configs/dataset_config.yml
StyleText/configs/dataset_config.yml
+0
-0
StyleText/doc/images/1.png
StyleText/doc/images/1.png
+0
-0
StyleText/doc/images/2.png
StyleText/doc/images/2.png
+0
-0
StyleText/doc/images/3.png
StyleText/doc/images/3.png
+0
-0
StyleText/doc/images/4.jpg
StyleText/doc/images/4.jpg
+0
-0
StyleText/doc/images/5.png
StyleText/doc/images/5.png
+0
-0
StyleText/doc/images/6.png
StyleText/doc/images/6.png
+0
-0
StyleText/engine/__init__.py
StyleText/engine/__init__.py
+0
-0
StyleText/engine/corpus_generators.py
StyleText/engine/corpus_generators.py
+0
-0
StyleText/engine/predictors.py
StyleText/engine/predictors.py
+0
-0
No files found.
StyleText
Rec
/README.md
→
StyleText/README.md
View file @
b91055ee
File moved
StyleText
Rec
/README_ch.md
→
StyleText/README_ch.md
View file @
b91055ee
## Style Text
Rec
## Style Text
### 目录
### 目录
-
[
工具简介
](
#工具简介
)
-
[
一、工具简介
](
#
一、工具简介)
-
[
环境配置
](
#环境配置
)
-
[
二、环境配置
](
#
二、环境配置)
-
[
快速上手
](
#快速上手
)
-
[
三、快速上手
](
#
三、快速上手)
-
[
高级使用
](
#高级使用
)
-
[
四、应用示例
](
#
四、应用示例)
-
[
应用示例
](
#应用示例
)
### 工具简介
###
一、
工具简介
<div
align=
"center"
>
<div
align=
"center"
>
<img
src=
"doc/images/3.png"
width=
"800"
>
<img
src=
"doc/images/3.png"
width=
"800"
>
</div>
</div>
...
@@ -23,13 +22,13 @@ Style-Text数据合成工具是基于百度自研的文本编辑算法《Editing
...
@@ -23,13 +22,13 @@ Style-Text数据合成工具是基于百度自研的文本编辑算法《Editing
<img
src=
"doc/images/2.png"
width=
"1000"
>
<img
src=
"doc/images/2.png"
width=
"1000"
>
</div>
</div>
### 环境配置
###
二、
环境配置
1.
参考
[
快速安装
](
../doc/doc_ch/installation.md
)
,安装PaddleOCR。
1.
参考
[
快速安装
](
../doc/doc_ch/installation.md
)
,安装PaddleOCR。
2.
进入
`
s
tyle
_t
ext
_rec
`
目录,下载模型,并解压:
2.
进入
`
S
tyle
T
ext`
目录,下载模型,并解压:
```
bash
```
bash
cd
s
tyle
_t
ext
_rec
cd
S
tyle
T
ext
wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/style_text/style_text_models.zip
wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/style_text/style_text_models.zip
unzip style_text_models.zip
unzip style_text_models.zip
```
```
...
@@ -47,7 +46,9 @@ fusion_generator:
...
@@ -47,7 +46,9 @@ fusion_generator:
pretrain: style_text_models/fusion_generator
pretrain: style_text_models/fusion_generator
```
```
### 快速上手
### 三、快速上手
#### 合成单张图
1.
运行tools/synth_image,生成示例图片:
1.
运行tools/synth_image,生成示例图片:
...
@@ -55,7 +56,7 @@ fusion_generator:
...
@@ -55,7 +56,7 @@ fusion_generator:
python3
-
m
tools
.
synth_image
-
c
configs
/
config
.
yml
python3
-
m
tools
.
synth_image
-
c
configs
/
config
.
yml
```
```
1
.
运行后,会生成
`fake_busion.jpg`
,即为最终结果。
2
.
运行后,会生成
`fake_busion.jpg`
,即为最终结果。
<div
align=
"center"
>
<div
align=
"center"
>
<img
src=
"doc/images/4.jpg"
width=
"300"
>
<img
src=
"doc/images/4.jpg"
width=
"300"
>
</div>
</div>
...
@@ -63,17 +64,17 @@ python3 -m tools.synth_image -c configs/config.yml
...
@@ -63,17 +64,17 @@ python3 -m tools.synth_image -c configs/config.yml
*
`fake_bg.jpg`
:为风格参考图去掉文字后的背景;
*
`fake_bg.jpg`
:为风格参考图去掉文字后的背景;
*
`fake_text.jpg`
:是用提供的字符串,仿照风格参考图中文字的风格,生成在灰色背景上的文字图片。
*
`fake_text.jpg`
:是用提供的字符串,仿照风格参考图中文字的风格,生成在灰色背景上的文字图片。
2
.
如果您想尝试其他风格图像和文字的效果,可以添加style_image,text_corpus和language参数:
3
.
如果您想尝试其他风格图像和文字的效果,可以添加style_image,text_corpus和language参数:
```
python
```
python
python3
-
m
tools
.
synth_image
-
c
configs
/
config
.
yml
--
style_image
examples
/
style_images
/
2.j
pg
--
text_corpus
PaddleOCR
--
language
en
python3
-
m
tools
.
synth_image
-
c
configs
/
config
.
yml
--
style_image
examples
/
style_images
/
2.j
pg
--
text_corpus
PaddleOCR
--
language
en
```
```
*
注意:语言选项和语料相对应,目前我们支持英文、简体中文和韩语。
*
注意:语言选项和语料相对应,目前我们支持英文、简体中文和韩语。
3
.
在
`tools/synth_image.py`
中,我们还提供了一个
`batch_synth_images`
方法,可以两两组合语料和图片,批量生成一批数据。
4
.
在
`tools/synth_image.py`
中,我们还提供了一个
`batch_synth_images`
方法,可以两两组合语料和图片,批量生成一批数据。
###
高级使用
###
# 批量合成
在开始合成数据
集
前,需要准备一些素材。
在开始合成数据前,需要准备一些素材。
首先,需要风格图片作为合成图片的参考依据,这些数据可以是用作训练OCR识别模型的数据集。本例中使用带有标注文件的数据集作为风格图片.
首先,需要风格图片作为合成图片的参考依据,这些数据可以是用作训练OCR识别模型的数据集。本例中使用带有标注文件的数据集作为风格图片.
...
@@ -88,7 +89,7 @@ python3 -m tools.synth_image -c configs/config.yml --style_image examples/style_
...
@@ -88,7 +89,7 @@ python3 -m tools.synth_image -c configs/config.yml --style_image examples/style_
*
`language`
:语料的语种;
*
`language`
:语料的语种;
*
`corpus_file`
: 语料文件路径。
*
`corpus_file`
: 语料文件路径。
我们提供了一批
[
样例图
](
https://paddleocr.bj.bcebos.com/dygraph_v2.0/style_text/chkoen_5w.tar
)
供您试用
,下面给出了一些示例:
我们提供了一批
中英韩5w通用数据供您试用 (
[
下载地址
](
https://paddleocr.bj.bcebos.com/dygraph_v2.0/style_text/chkoen_5w.tar
)
)
,下面给出了一些示例:
<div
align=
"center"
>
<div
align=
"center"
>
<img
src=
"doc/images/5.png"
width=
"800"
>
<img
src=
"doc/images/5.png"
width=
"800"
>
</div>
</div>
...
@@ -106,21 +107,22 @@ python3 -m tools.synth_image -c configs/config.yml --style_image examples/style_
...
@@ -106,21 +107,22 @@ python3 -m tools.synth_image -c configs/config.yml --style_image examples/style_
```
```
### 应用示例
###
四、
应用示例
在完成上述操作后,即可得到用于OCR识别的合成数据集,下面给出了一些数据集生成的示例:
在完成上述操作后,即可得到用于OCR识别的合成数据集。在实用场景中,我们经常遇到数据量不足的情况,这时可以使用已有数据作为style_input,合成数据。
下面给出了一些数据集生成的示例:
<div
align=
"center"
>
<div
align=
"center"
>
<img
src=
"doc/images/6.png"
width=
"800"
>
<img
src=
"doc/images/6.png"
width=
"800"
>
</div>
</div>
请您参考
[
OCR识别文档
](
https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/doc/doc_ch/recognition.md#%E5%90%AF%E5%8A%A8%E8%AE%AD%E7%BB%83
)
,完成训练。
下面展示了一些使用合成数据训练的效果
:
在添加这些合成数据进行训练后,识别模型的效果得到了显著提升,如下表所示
:
| 场景 | 字符 | 原始数据 | 测试数据 | 只使用原始数据的识别准确率 | 新增合成数据 | 使用合成数据识别准确率 | 指标提升 |
| 场景 | 字符 | 原始数据 | 测试数据 | 只使用原始数据的识别准确率 | 新增合成数据 | 使用合成数据识别准确率 | 指标提升 |
| -------- | ---------- | -------- | -------- | -------------------------- | ------------ | ---------------------- | -------- |
| -------- | ---------- | -------- | -------- | -------------------------- | ------------ | ---------------------- | -------- |
| 金属表面 | 英文和数字 | 2203 | 650 | 0.5938 | 20000 | 0.7546 | 16% |
| 金属表面 | 英文和数字 | 2203 | 650 | 0.5938 | 20000 | 0.7546 | 16% |
| 随机背景 | 韩语 | 5631 | 1230 | 0.3012 | 100000 | 0.5057 | 20% |
| 随机背景 | 韩语 | 5631 | 1230 | 0.3012 | 100000 | 0.5057 | 20% |
识别模型的训练方法您可以参考
[
OCR识别文档
](
../doc/doc_ch/recognition.md
)
### 项目结构
### 项目结构
```
```
style_text_rec
style_text_rec
...
...
StyleText
Rec
/__init__.py
→
StyleText/__init__.py
View file @
b91055ee
File moved
StyleText
Rec
/arch/__init__.py
→
StyleText/arch/__init__.py
View file @
b91055ee
File moved
StyleText
Rec
/arch/base_module.py
→
StyleText/arch/base_module.py
View file @
b91055ee
File moved
StyleText
Rec
/arch/decoder.py
→
StyleText/arch/decoder.py
View file @
b91055ee
File moved
StyleText
Rec
/arch/encoder.py
→
StyleText/arch/encoder.py
View file @
b91055ee
File moved
StyleText
Rec
/arch/spectral_norm.py
→
StyleText/arch/spectral_norm.py
View file @
b91055ee
File moved
StyleText
Rec
/arch/style_text_rec.py
→
StyleText/arch/style_text_rec.py
View file @
b91055ee
File moved
StyleText
Rec
/configs/config.yml
→
StyleText/configs/config.yml
View file @
b91055ee
File moved
StyleText
Rec
/configs/dataset_config.yml
→
StyleText/configs/dataset_config.yml
View file @
b91055ee
File moved
StyleText
Rec
/doc/images/1.png
→
StyleText/doc/images/1.png
View file @
b91055ee
File moved
StyleText
Rec
/doc/images/2.png
→
StyleText/doc/images/2.png
View file @
b91055ee
File moved
StyleText
Rec
/doc/images/3.png
→
StyleText/doc/images/3.png
View file @
b91055ee
File moved
StyleText
Rec
/doc/images/4.jpg
→
StyleText/doc/images/4.jpg
View file @
b91055ee
File moved
StyleText
Rec
/doc/images/5.png
→
StyleText/doc/images/5.png
View replaced file @
703bb1a9
View file @
b91055ee
122 KB
|
W:
|
H:
118 KB
|
W:
|
H:
2-up
Swipe
Onion skin
StyleText
Rec
/doc/images/6.png
→
StyleText/doc/images/6.png
View file @
b91055ee
File moved
StyleText
Rec
/engine/__init__.py
→
StyleText/engine/__init__.py
View file @
b91055ee
File moved
StyleText
Rec
/engine/corpus_generators.py
→
StyleText/engine/corpus_generators.py
View file @
b91055ee
File moved
StyleText
Rec
/engine/predictors.py
→
StyleText/engine/predictors.py
View file @
b91055ee
File moved
Prev
1
2
Next
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