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
5e9fb50d
Commit
5e9fb50d
authored
Jan 26, 2021
by
tink2123
Browse files
Merge branch 'dygraph' of
https://github.com/PaddlePaddle/PaddleOCR
into multi_languages
parents
45117f90
5a5d627d
Changes
84
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
14 deletions
+15
-14
ppocr/data/simple_dataset.py
ppocr/data/simple_dataset.py
+4
-1
ppocr/modeling/transforms/tps.py
ppocr/modeling/transforms/tps.py
+8
-10
ppocr/postprocess/rec_postprocess.py
ppocr/postprocess/rec_postprocess.py
+1
-1
tools/program.py
tools/program.py
+2
-2
No files found.
ppocr/data/simple_dataset.py
View file @
5e9fb50d
...
...
@@ -20,7 +20,7 @@ from .imaug import transform, create_operators
class
SimpleDataSet
(
Dataset
):
def
__init__
(
self
,
config
,
mode
,
logger
):
def
__init__
(
self
,
config
,
mode
,
logger
,
seed
=
None
):
super
(
SimpleDataSet
,
self
).
__init__
()
self
.
logger
=
logger
...
...
@@ -41,6 +41,7 @@ class SimpleDataSet(Dataset):
self
.
data_dir
=
dataset_config
[
'data_dir'
]
self
.
do_shuffle
=
loader_config
[
'shuffle'
]
self
.
seed
=
seed
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_idx_order_list
=
list
(
range
(
len
(
self
.
data_lines
)))
...
...
@@ -55,6 +56,7 @@ class SimpleDataSet(Dataset):
for
idx
,
file
in
enumerate
(
file_list
):
with
open
(
file
,
"rb"
)
as
f
:
lines
=
f
.
readlines
()
random
.
seed
(
self
.
seed
)
lines
=
random
.
sample
(
lines
,
round
(
len
(
lines
)
*
ratio_list
[
idx
]))
data_lines
.
extend
(
lines
)
...
...
@@ -62,6 +64,7 @@ class SimpleDataSet(Dataset):
def
shuffle_data_random
(
self
):
if
self
.
do_shuffle
:
random
.
seed
(
self
.
seed
)
random
.
shuffle
(
self
.
data_lines
)
return
...
...
ppocr/modeling/transforms/tps.py
View file @
5e9fb50d
...
...
@@ -213,16 +213,14 @@ class GridGenerator(nn.Layer):
def
build_P_paddle
(
self
,
I_r_size
):
I_r_height
,
I_r_width
=
I_r_size
I_r_grid_x
=
paddle
.
divide
(
paddle
.
arange
(
-
I_r_width
,
I_r_width
,
2
,
dtype
=
'float64'
)
+
1.0
,
paddle
.
to_tensor
(
I_r_width
,
dtype
=
'float64'
))
I_r_grid_y
=
paddle
.
divide
(
paddle
.
arange
(
-
I_r_height
,
I_r_height
,
2
,
dtype
=
'float64'
)
+
1.0
,
paddle
.
to_tensor
(
I_r_height
,
dtype
=
'float64'
))
# self.I_r_height
I_r_grid_x
=
(
paddle
.
arange
(
-
I_r_width
,
I_r_width
,
2
,
dtype
=
'float64'
)
+
1.0
)
/
paddle
.
to_tensor
(
np
.
array
([
I_r_width
]))
I_r_grid_y
=
(
paddle
.
arange
(
-
I_r_height
,
I_r_height
,
2
,
dtype
=
'float64'
)
+
1.0
)
/
paddle
.
to_tensor
(
np
.
array
([
I_r_height
]))
# P: self.I_r_width x self.I_r_height x 2
P
=
paddle
.
stack
(
paddle
.
meshgrid
(
I_r_grid_x
,
I_r_grid_y
),
axis
=
2
)
P
=
paddle
.
transpose
(
P
,
perm
=
[
1
,
0
,
2
])
...
...
ppocr/postprocess/rec_postprocess.py
View file @
5e9fb50d
...
...
@@ -109,7 +109,7 @@ class CTCLabelDecode(BaseRecLabelDecode):
preds_idx
=
preds
.
argmax
(
axis
=
2
)
preds_prob
=
preds
.
max
(
axis
=
2
)
text
=
self
.
decode
(
preds_idx
,
preds_prob
)
text
=
self
.
decode
(
preds_idx
,
preds_prob
,
is_remove_duplicate
=
True
)
if
label
is
None
:
return
text
label
=
self
.
decode
(
label
)
...
...
tools/program.py
View file @
5e9fb50d
...
...
@@ -182,8 +182,8 @@ def train(config,
start_epoch
=
1
for
epoch
in
range
(
start_epoch
,
epoch_num
+
1
):
if
epoch
>
0
:
train_dataloader
=
build_dataloader
(
config
,
'Train'
,
device
,
logger
)
train_dataloader
=
build_dataloader
(
config
,
'Train'
,
device
,
logger
,
seed
=
epoch
)
train_batch_cost
=
0.0
train_reader_cost
=
0.0
batch_sum
=
0
...
...
Prev
1
2
3
4
5
Next
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