Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
80c18878
P
PaddleOCR
项目概览
PaddlePaddle
/
PaddleOCR
大约 1 年 前同步成功
通知
1528
Star
32962
Fork
6643
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
108
列表
看板
标记
里程碑
合并请求
7
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
108
Issue
108
列表
看板
标记
里程碑
合并请求
7
合并请求
7
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
80c18878
编写于
6月 03, 2020
作者:
T
tink2123
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix eval
上级
be3a1644
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
19 addition
and
11 deletion
+19
-11
ppocr/data/rec/dataset_traversal.py
ppocr/data/rec/dataset_traversal.py
+12
-5
ppocr/data/rec/img_tools.py
ppocr/data/rec/img_tools.py
+4
-3
ppocr/modeling/architectures/rec_model.py
ppocr/modeling/architectures/rec_model.py
+3
-3
未找到文件。
ppocr/data/rec/dataset_traversal.py
浏览文件 @
80c18878
...
...
@@ -41,6 +41,7 @@ class LMDBReader(object):
self
.
loss_type
=
params
[
'loss_type'
]
self
.
max_text_length
=
params
[
'max_text_length'
]
self
.
mode
=
params
[
'mode'
]
self
.
drop_last
=
False
if
"tps"
in
params
:
self
.
tps
=
True
if
params
[
'mode'
]
==
'train'
:
...
...
@@ -112,7 +113,8 @@ class LMDBReader(object):
img
=
img
,
image_shape
=
self
.
image_shape
,
char_ops
=
self
.
char_ops
,
tps
=
self
.
tps
)
tps
=
self
.
tps
,
infer_mode
=
True
)
yield
norm_img
else
:
lmdb_sets
=
self
.
load_hierarchical_lmdb_dataset
()
...
...
@@ -132,9 +134,13 @@ class LMDBReader(object):
if
sample_info
is
None
:
continue
img
,
label
=
sample_info
outs
=
process_image
(
img
,
self
.
image_shape
,
label
,
self
.
char_ops
,
self
.
loss_type
,
self
.
max_text_length
)
outs
=
process_image
(
img
=
img
,
image_shape
=
self
.
image_shape
,
label
=
label
,
char_ops
=
self
.
char_ops
,
loss_type
=
self
.
loss_type
,
max_text_length
=
self
.
max_text_length
)
if
outs
is
None
:
continue
yield
outs
...
...
@@ -154,7 +160,7 @@ class LMDBReader(object):
if
len
(
batch_outs
)
!=
0
:
yield
batch_outs
if
self
.
mode
!=
'train'
and
self
.
infer_img
is
None
:
if
self
.
infer_img
is
None
:
return
batch_iter_reader
return
sample_iter_reader
...
...
@@ -174,6 +180,7 @@ class SimpleReader(object):
self
.
max_text_length
=
params
[
'max_text_length'
]
self
.
mode
=
params
[
'mode'
]
self
.
infer_img
=
params
[
'infer_img'
]
self
.
drop_last
=
False
if
params
[
'mode'
]
==
'train'
:
self
.
batch_size
=
params
[
'train_batch_size_per_card'
]
self
.
drop_last
=
params
[
'drop_last'
]
...
...
ppocr/data/rec/img_tools.py
浏览文件 @
80c18878
...
...
@@ -93,11 +93,12 @@ def process_image(img,
char_ops
=
None
,
loss_type
=
None
,
max_text_length
=
None
,
tps
=
None
):
if
char_ops
.
character_type
==
"en"
:
tps
=
None
,
infer_mode
=
False
):
if
not
infer_mode
or
char_ops
.
character_type
==
"en"
:
norm_img
=
resize_norm_img
(
img
,
image_shape
)
else
:
if
tps
:
if
tps
!=
None
and
char_ops
.
character_type
==
"ch"
:
image_shape
=
[
3
,
32
,
320
]
norm_img
=
resize_norm_img
(
img
,
image_shape
)
else
:
...
...
ppocr/modeling/architectures/rec_model.py
浏览文件 @
80c18878
...
...
@@ -31,6 +31,7 @@ class RecModel(object):
char_num
=
global_params
[
'char_ops'
].
get_char_num
()
global_params
[
'char_num'
]
=
char_num
self
.
char_type
=
global_params
[
'character_type'
]
self
.
infer_img
=
global_params
[
'infer_img'
]
if
"TPS"
in
params
:
tps_params
=
deepcopy
(
params
[
"TPS"
])
tps_params
.
update
(
global_params
)
...
...
@@ -87,7 +88,7 @@ class RecModel(object):
use_double_buffer
=
True
,
iterable
=
False
)
else
:
if
self
.
char_type
==
"ch"
:
if
self
.
char_type
==
"ch"
and
self
.
infer_img
:
image_shape
[
-
1
]
=
-
1
if
self
.
tps
!=
None
:
logger
.
info
(
...
...
@@ -96,8 +97,7 @@ class RecModel(object):
"We set default shape=[3,32,320], it may affect the inference effect"
)
image_shape
[
-
1
]
=
320
image
=
fluid
.
data
(
name
=
'image'
,
shape
=
image_shape
,
dtype
=
'float32'
)
image
=
fluid
.
data
(
name
=
'image'
,
shape
=
image_shape
,
dtype
=
'float32'
)
labels
=
None
loader
=
None
return
image
,
labels
,
loader
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录