Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
d6ee6bdb
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看板
未验证
提交
d6ee6bdb
编写于
3月 31, 2021
作者:
D
Double_V
提交者:
GitHub
3月 31, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2347 from littletomatodonkey/dyg/fix_pre_rec
fix eval res vary for different times
上级
76946e83
113d8a8e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
8 deletion
+12
-8
ppocr/data/simple_dataset.py
ppocr/data/simple_dataset.py
+12
-8
未找到文件。
ppocr/data/simple_dataset.py
浏览文件 @
d6ee6bdb
...
@@ -23,6 +23,7 @@ class SimpleDataSet(Dataset):
...
@@ -23,6 +23,7 @@ class SimpleDataSet(Dataset):
def
__init__
(
self
,
config
,
mode
,
logger
,
seed
=
None
):
def
__init__
(
self
,
config
,
mode
,
logger
,
seed
=
None
):
super
(
SimpleDataSet
,
self
).
__init__
()
super
(
SimpleDataSet
,
self
).
__init__
()
self
.
logger
=
logger
self
.
logger
=
logger
self
.
mode
=
mode
.
lower
()
global_config
=
config
[
'Global'
]
global_config
=
config
[
'Global'
]
dataset_config
=
config
[
mode
][
'dataset'
]
dataset_config
=
config
[
mode
][
'dataset'
]
...
@@ -45,7 +46,7 @@ class SimpleDataSet(Dataset):
...
@@ -45,7 +46,7 @@ class SimpleDataSet(Dataset):
logger
.
info
(
"Initialize indexs of datasets:%s"
%
label_file_list
)
logger
.
info
(
"Initialize indexs of datasets:%s"
%
label_file_list
)
self
.
data_lines
=
self
.
get_image_info_list
(
label_file_list
,
ratio_list
)
self
.
data_lines
=
self
.
get_image_info_list
(
label_file_list
,
ratio_list
)
self
.
data_idx_order_list
=
list
(
range
(
len
(
self
.
data_lines
)))
self
.
data_idx_order_list
=
list
(
range
(
len
(
self
.
data_lines
)))
if
mode
.
lower
()
==
"train"
:
if
self
.
mode
==
"train"
and
self
.
do_shuffle
:
self
.
shuffle_data_random
()
self
.
shuffle_data_random
()
self
.
ops
=
create_operators
(
dataset_config
[
'transforms'
],
global_config
)
self
.
ops
=
create_operators
(
dataset_config
[
'transforms'
],
global_config
)
...
@@ -56,16 +57,16 @@ class SimpleDataSet(Dataset):
...
@@ -56,16 +57,16 @@ class SimpleDataSet(Dataset):
for
idx
,
file
in
enumerate
(
file_list
):
for
idx
,
file
in
enumerate
(
file_list
):
with
open
(
file
,
"rb"
)
as
f
:
with
open
(
file
,
"rb"
)
as
f
:
lines
=
f
.
readlines
()
lines
=
f
.
readlines
()
random
.
seed
(
self
.
seed
)
if
self
.
mode
==
"train"
or
ratio_list
[
idx
]
<
1.0
:
lines
=
random
.
sample
(
lines
,
random
.
seed
(
self
.
seed
)
round
(
len
(
lines
)
*
ratio_list
[
idx
]))
lines
=
random
.
sample
(
lines
,
round
(
len
(
lines
)
*
ratio_list
[
idx
]))
data_lines
.
extend
(
lines
)
data_lines
.
extend
(
lines
)
return
data_lines
return
data_lines
def
shuffle_data_random
(
self
):
def
shuffle_data_random
(
self
):
if
self
.
do_shuffle
:
random
.
seed
(
self
.
seed
)
random
.
seed
(
self
.
seed
)
random
.
shuffle
(
self
.
data_lines
)
random
.
shuffle
(
self
.
data_lines
)
return
return
def
__getitem__
(
self
,
idx
):
def
__getitem__
(
self
,
idx
):
...
@@ -90,7 +91,10 @@ class SimpleDataSet(Dataset):
...
@@ -90,7 +91,10 @@ class SimpleDataSet(Dataset):
data_line
,
e
))
data_line
,
e
))
outs
=
None
outs
=
None
if
outs
is
None
:
if
outs
is
None
:
return
self
.
__getitem__
(
np
.
random
.
randint
(
self
.
__len__
()))
# during evaluation, we should fix the idx to get same results for many times of evaluation.
rnd_idx
=
np
.
random
.
randint
(
self
.
__len__
(
))
if
self
.
mode
==
"train"
else
(
idx
+
1
)
%
self
.
__len__
()
return
self
.
__getitem__
(
rnd_idx
)
return
outs
return
outs
def
__len__
(
self
):
def
__len__
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录