Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
paddle_dbnet
Commits
d97d98fe
Commit
d97d98fe
authored
Dec 10, 2020
by
LDOUBLEV
Browse files
opt random sample
parent
b8ba7035
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
7 deletions
+2
-7
ppocr/data/simple_dataset.py
ppocr/data/simple_dataset.py
+2
-7
No files found.
ppocr/data/simple_dataset.py
View file @
d97d98fe
...
...
@@ -48,12 +48,6 @@ class SimpleDataSet(Dataset):
self
.
shuffle_data_random
()
self
.
ops
=
create_operators
(
dataset_config
[
'transforms'
],
global_config
)
def
_sample_dataset
(
self
,
datas
,
sample_ratio
):
sample_num
=
round
(
len
(
datas
)
*
sample_ratio
)
nums
,
rem
=
int
(
sample_num
//
len
(
datas
)),
int
(
sample_num
%
len
(
datas
))
return
list
(
datas
)
*
nums
+
random
.
sample
(
datas
,
rem
)
def
get_image_info_list
(
self
,
file_list
,
ratio_list
):
if
isinstance
(
file_list
,
str
):
file_list
=
[
file_list
]
...
...
@@ -61,7 +55,8 @@ class SimpleDataSet(Dataset):
for
idx
,
file
in
enumerate
(
file_list
):
with
open
(
file
,
"rb"
)
as
f
:
lines
=
f
.
readlines
()
lines
=
self
.
_sample_dataset
(
lines
,
ratio_list
[
idx
])
lines
=
random
.
sample
(
lines
,
round
(
len
(
lines
)
*
ratio_list
[
idx
]))
data_lines
.
extend
(
lines
)
return
data_lines
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment