Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleOCR
提交
dd0112f5
P
PaddleOCR
项目概览
s920243400
/
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看板
提交
dd0112f5
编写于
5月 21, 2020
作者:
T
tink2123
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix infer_rec for benchmark
上级
6de43fbb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
45 addition
and
32 deletion
+45
-32
configs/rec/rec_benchmark_reader.yml
configs/rec/rec_benchmark_reader.yml
+2
-1
ppocr/data/rec/dataset_traversal.py
ppocr/data/rec/dataset_traversal.py
+43
-31
未找到文件。
configs/rec/rec_benchmark_reader.yml
浏览文件 @
dd0112f5
...
...
@@ -9,4 +9,5 @@ EvalReader:
TestReader
:
reader_function
:
ppocr.data.rec.dataset_traversal,LMDBReader
lmdb_sets_dir
:
./train_data/data_lmdb_release/evaluation/
\ No newline at end of file
lmdb_sets_dir
:
./train_data/data_lmdb_release/evaluation/
infer_img
:
ppocr/data/rec/dataset_traversal.py
浏览文件 @
dd0112f5
...
...
@@ -42,9 +42,11 @@ class LMDBReader(object):
self
.
mode
=
params
[
'mode'
]
if
params
[
'mode'
]
==
'train'
:
self
.
batch_size
=
params
[
'train_batch_size_per_card'
]
el
se
:
el
if
params
[
'mode'
]
==
"eval"
:
self
.
batch_size
=
params
[
'test_batch_size_per_card'
]
elif
params
[
'mode'
]
==
"test"
:
self
.
batch_size
=
1
self
.
infer_img
=
params
[
"infer_img"
]
def
load_hierarchical_lmdb_dataset
(
self
):
lmdb_sets
=
{}
dataset_idx
=
0
...
...
@@ -97,34 +99,42 @@ class LMDBReader(object):
process_id
=
0
def
sample_iter_reader
():
lmdb_sets
=
self
.
load_hierarchical_lmdb_dataset
()
if
process_id
==
0
:
self
.
print_lmdb_sets_info
(
lmdb_sets
)
cur_index_sets
=
[
1
+
process_id
]
*
len
(
lmdb_sets
)
while
True
:
finish_read_num
=
0
for
dataset_idx
in
range
(
len
(
lmdb_sets
)):
cur_index
=
cur_index_sets
[
dataset_idx
]
if
cur_index
>
lmdb_sets
[
dataset_idx
][
'num_samples'
]:
finish_read_num
+=
1
else
:
sample_info
=
self
.
get_lmdb_sample_info
(
lmdb_sets
[
dataset_idx
][
'txn'
],
cur_index
)
cur_index_sets
[
dataset_idx
]
+=
self
.
num_workers
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
)
if
outs
is
None
:
continue
yield
outs
if
finish_read_num
==
len
(
lmdb_sets
):
break
self
.
close_lmdb_dataset
(
lmdb_sets
)
if
self
.
mode
==
'test'
:
image_file_list
=
get_image_file_list
(
self
.
infer_img
)
for
single_img
in
image_file_list
:
img
=
cv2
.
imread
(
single_img
)
if
img
.
shape
[
-
1
]
==
1
or
len
(
list
(
img
.
shape
))
==
2
:
img
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_GRAY2BGR
)
norm_img
=
process_image
(
img
,
self
.
image_shape
)
yield
norm_img
else
:
lmdb_sets
=
self
.
load_hierarchical_lmdb_dataset
()
if
process_id
==
0
:
self
.
print_lmdb_sets_info
(
lmdb_sets
)
cur_index_sets
=
[
1
+
process_id
]
*
len
(
lmdb_sets
)
while
True
:
finish_read_num
=
0
for
dataset_idx
in
range
(
len
(
lmdb_sets
)):
cur_index
=
cur_index_sets
[
dataset_idx
]
if
cur_index
>
lmdb_sets
[
dataset_idx
][
'num_samples'
]:
finish_read_num
+=
1
else
:
sample_info
=
self
.
get_lmdb_sample_info
(
lmdb_sets
[
dataset_idx
][
'txn'
],
cur_index
)
cur_index_sets
[
dataset_idx
]
+=
self
.
num_workers
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
)
if
outs
is
None
:
continue
yield
outs
if
finish_read_num
==
len
(
lmdb_sets
):
break
self
.
close_lmdb_dataset
(
lmdb_sets
)
def
batch_iter_reader
():
batch_outs
=
[]
for
outs
in
sample_iter_reader
():
...
...
@@ -135,7 +145,9 @@ class LMDBReader(object):
if
len
(
batch_outs
)
!=
0
:
yield
batch_outs
return
batch_iter_reader
if
self
.
mode
!=
'test'
:
return
batch_iter_reader
return
sample_iter_reader
class
SimpleReader
(
object
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录