Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
fc85051d
P
PaddleOCR
项目概览
weixin_41840029
/
PaddleOCR
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleOCR
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
fc85051d
编写于
12月 17, 2020
作者:
L
littletomatodonkey
提交者:
GitHub
12月 17, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add support for cpu infer (#1480)
* add support for cpu infer * fix readme
上级
84b4323a
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
21 addition
and
10 deletion
+21
-10
StyleText/README.md
StyleText/README.md
+6
-5
StyleText/README_ch.md
StyleText/README_ch.md
+3
-2
StyleText/engine/predictors.py
StyleText/engine/predictors.py
+1
-0
StyleText/tools/synth_dataset.py
StyleText/tools/synth_dataset.py
+8
-0
StyleText/tools/synth_image.py
StyleText/tools/synth_image.py
+3
-3
未找到文件。
StyleText/README.md
浏览文件 @
fc85051d
...
...
@@ -69,12 +69,13 @@ fusion_generator:
1.
You can run
`tools/synth_image`
and generate the demo image, which is saved in the current folder.
```
python
python3
-
m
tools
.
synth_image
-
c
configs
/
config
.
yml
--
style_image
examples
/
style_images
/
2.j
pg
--
text_corpus
PaddleOCR
--
language
en
python3
tools
/
synth_image
.
py
-
c
configs
/
config
.
yml
--
style_image
examples
/
style_images
/
2.j
pg
--
text_corpus
PaddleOCR
--
language
en
```
*
Note 1: The language options is correspond to the corpus. Currently, the tool only supports English, Simplified Chinese and Korean.
*
Note 2: Synth-Text is mainly used to generate images for OCR recognition models.
So the height of style images should be around 32 pixels. Images in other sizes may behave poorly.
*
Note 3: You can modify
`use_gpu`
in
`configs/config.yml`
to determine whether to use GPU for prediction.
For example, enter the following image and corpus
`PaddleOCR`
.
...
...
@@ -139,7 +140,7 @@ We provide a general dataset containing Chinese, English and Korean (50,000 imag
2.
You can run the following command to start synthesis task:
```
bash
python
-m
tools.
synth_dataset.py
-c
configs/dataset_config.yml
python
3 tools/
synth_dataset.py
-c
configs/dataset_config.yml
```
We also provide example corpus and images in
`examples`
folder.
<div
align=
"center"
>
...
...
StyleText/README_ch.md
浏览文件 @
fc85051d
...
...
@@ -61,11 +61,12 @@ fusion_generator:
输入一张风格图和一段文字语料,运行tools/synth_image,合成单张图片,结果图像保存在当前目录下:
```
python
python3
-
m
tools
.
synth_image
-
c
configs
/
config
.
yml
--
style_image
examples
/
style_images
/
2.j
pg
--
text_corpus
PaddleOCR
--
language
en
python3
tools
/
synth_image
.
py
-
c
configs
/
config
.
yml
--
style_image
examples
/
style_images
/
2.j
pg
--
text_corpus
PaddleOCR
--
language
en
```
*
注1:语言选项和语料相对应,目前该工具只支持英文、简体中文和韩语。
*
注2:Style-Text生成的数据主要应用于OCR识别场景。基于当前PaddleOCR识别模型的设计,我们主要支持高度在32左右的风格图像。
如果输入图像尺寸相差过多,效果可能不佳。
*
注3:可以通过修改配置文件中的
`use_gpu`
(true或者false)参数来决定是否使用GPU进行预测。
例如,输入如下图片和语料"PaddleOCR":
...
...
@@ -127,7 +128,7 @@ python3 -m tools.synth_image -c configs/config.yml --style_image examples/style_
2.
运行
`tools/synth_dataset`
合成数据:
```
bash
python
-m
tools.synth_dataset
-c
configs/dataset_config.yml
python
tools/synth_dataset.py
-c
configs/dataset_config.yml
```
我们在examples目录下提供了样例图片和语料。
<div
align=
"center"
>
...
...
StyleText/engine/predictors.py
浏览文件 @
fc85051d
...
...
@@ -28,6 +28,7 @@ class StyleTextRecPredictor(object):
],
"Generator {} not supported."
.
format
(
algorithm
)
use_gpu
=
config
[
"Global"
][
'use_gpu'
]
check_gpu
(
use_gpu
)
paddle
.
set_device
(
'gpu'
if
use_gpu
else
'cpu'
)
self
.
logger
=
get_logger
()
self
.
generator
=
getattr
(
style_text_rec
,
algorithm
)(
config
)
self
.
height
=
config
[
"Global"
][
"image_height"
]
...
...
StyleText/tools/synth_dataset.py
浏览文件 @
fc85051d
...
...
@@ -11,6 +11,14 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
os
import
sys
__dir__
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
sys
.
path
.
append
(
__dir__
)
sys
.
path
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
__dir__
,
'..'
)))
from
engine.synthesisers
import
DatasetSynthesiser
...
...
StyleText/tools/synth_image.py
浏览文件 @
fc85051d
...
...
@@ -16,13 +16,13 @@ import cv2
import
sys
import
glob
from
utils.config
import
ArgsParser
from
engine.synthesisers
import
ImageSynthesiser
__dir__
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
sys
.
path
.
append
(
__dir__
)
sys
.
path
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
__dir__
,
'..'
)))
from
utils.config
import
ArgsParser
from
engine.synthesisers
import
ImageSynthesiser
def
synth_image
():
args
=
ArgsParser
().
parse_args
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录