Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
b8ba7035
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看板
提交
b8ba7035
编写于
12月 10, 2020
作者:
L
LDOUBLEV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
delete data_num_per_epoch
上级
e23c4de5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
5 addition
and
17 deletion
+5
-17
ppocr/data/simple_dataset.py
ppocr/data/simple_dataset.py
+5
-17
未找到文件。
ppocr/data/simple_dataset.py
浏览文件 @
b8ba7035
...
@@ -27,17 +27,13 @@ class SimpleDataSet(Dataset):
...
@@ -27,17 +27,13 @@ class SimpleDataSet(Dataset):
global_config
=
config
[
'Global'
]
global_config
=
config
[
'Global'
]
dataset_config
=
config
[
mode
][
'dataset'
]
dataset_config
=
config
[
mode
][
'dataset'
]
loader_config
=
config
[
mode
][
'loader'
]
loader_config
=
config
[
mode
][
'loader'
]
if
'data_num_per_epoch'
in
loader_config
.
keys
():
data_num_per_epoch
=
loader_config
[
'data_num_per_epoch'
]
else
:
data_num_per_epoch
=
None
self
.
delimiter
=
dataset_config
.
get
(
'delimiter'
,
'
\t
'
)
self
.
delimiter
=
dataset_config
.
get
(
'delimiter'
,
'
\t
'
)
label_file_list
=
dataset_config
.
pop
(
'label_file_list'
)
label_file_list
=
dataset_config
.
pop
(
'label_file_list'
)
data_source_num
=
len
(
label_file_list
)
data_source_num
=
len
(
label_file_list
)
ratio_list
=
dataset_config
.
get
(
"ratio_list"
,
[
1.0
])
ratio_list
=
dataset_config
.
get
(
"ratio_list"
,
[
1.0
])
if
isinstance
(
ratio_list
,
(
float
,
int
)):
if
isinstance
(
ratio_list
,
(
float
,
int
)):
ratio_list
=
[
float
(
ratio_list
)]
*
len
(
data_source_num
)
ratio_list
=
[
float
(
ratio_list
)]
*
int
(
data_source_num
)
assert
len
(
assert
len
(
ratio_list
ratio_list
...
@@ -46,34 +42,26 @@ class SimpleDataSet(Dataset):
...
@@ -46,34 +42,26 @@ class SimpleDataSet(Dataset):
self
.
do_shuffle
=
loader_config
[
'shuffle'
]
self
.
do_shuffle
=
loader_config
[
'shuffle'
]
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
)
data_num_per_epoch
)
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
mode
.
lower
()
==
"train"
:
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
)
def
_sample_dataset
(
self
,
datas
,
sample_ratio
,
data_num_per_epoch
=
None
):
def
_sample_dataset
(
self
,
datas
,
sample_ratio
):
sample_num
=
round
(
len
(
datas
)
*
sample_ratio
)
sample_num
=
round
(
len
(
datas
)
*
sample_ratio
)
if
data_num_per_epoch
is
not
None
:
sample_num
=
int
(
data_num_per_epoch
*
sample_ratio
)
nums
,
rem
=
int
(
sample_num
//
len
(
datas
)),
int
(
sample_num
%
len
(
datas
))
nums
,
rem
=
int
(
sample_num
//
len
(
datas
)),
int
(
sample_num
%
len
(
datas
))
return
list
(
datas
)
*
nums
+
random
.
sample
(
datas
,
rem
)
return
list
(
datas
)
*
nums
+
random
.
sample
(
datas
,
rem
)
def
get_image_info_list
(
self
,
def
get_image_info_list
(
self
,
file_list
,
ratio_list
):
file_list
,
ratio_list
,
data_num_per_epoch
=
None
):
if
isinstance
(
file_list
,
str
):
if
isinstance
(
file_list
,
str
):
file_list
=
[
file_list
]
file_list
=
[
file_list
]
data_lines
=
[]
data_lines
=
[]
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
()
lines
=
self
.
_sample_dataset
(
lines
,
ratio_list
[
idx
],
lines
=
self
.
_sample_dataset
(
lines
,
ratio_list
[
idx
])
data_num_per_epoch
)
data_lines
.
extend
(
lines
)
data_lines
.
extend
(
lines
)
return
data_lines
return
data_lines
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录