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
1b959e3e
Commit
1b959e3e
authored
Apr 25, 2021
by
littletomatodonkey
Browse files
add save rec res
parent
05975f84
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
50 additions
and
28 deletions
+50
-28
configs/rec/ch_ppocr_v2.0/rec_chinese_common_train_v2.0.yml
configs/rec/ch_ppocr_v2.0/rec_chinese_common_train_v2.0.yml
+1
-0
configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml
configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml
+1
-0
configs/rec/rec_icdar15_train.yml
configs/rec/rec_icdar15_train.yml
+1
-0
configs/rec/rec_mv3_none_bilstm_ctc.yml
configs/rec/rec_mv3_none_bilstm_ctc.yml
+1
-0
configs/rec/rec_mv3_none_none_ctc.yml
configs/rec/rec_mv3_none_none_ctc.yml
+1
-0
configs/rec/rec_mv3_tps_bilstm_att.yml
configs/rec/rec_mv3_tps_bilstm_att.yml
+1
-0
configs/rec/rec_mv3_tps_bilstm_ctc.yml
configs/rec/rec_mv3_tps_bilstm_ctc.yml
+1
-0
configs/rec/rec_r34_vd_none_bilstm_ctc.yml
configs/rec/rec_r34_vd_none_bilstm_ctc.yml
+1
-0
configs/rec/rec_r34_vd_none_none_ctc.yml
configs/rec/rec_r34_vd_none_none_ctc.yml
+1
-0
configs/rec/rec_r34_vd_tps_bilstm_att.yml
configs/rec/rec_r34_vd_tps_bilstm_att.yml
+1
-0
configs/rec/rec_r34_vd_tps_bilstm_ctc.yml
configs/rec/rec_r34_vd_tps_bilstm_ctc.yml
+1
-0
configs/rec/rec_r50_fpn_srn.yml
configs/rec/rec_r50_fpn_srn.yml
+1
-0
tools/infer_rec.py
tools/infer_rec.py
+38
-28
No files found.
configs/rec/ch_ppocr_v2.0/rec_chinese_common_train_v2.0.yml
View file @
1b959e3e
...
...
@@ -19,6 +19,7 @@ Global:
max_text_length
:
25
infer_mode
:
False
use_space_char
:
True
save_res_path
:
./output/rec/predicts_chinese_common_v2.0.txt
Optimizer
:
...
...
configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml
View file @
1b959e3e
...
...
@@ -19,6 +19,7 @@ Global:
max_text_length
:
25
infer_mode
:
False
use_space_char
:
True
# save_res_path: ./output/rec/predicts_chinese_lite_v2.0.txt
Optimizer
:
...
...
configs/rec/rec_icdar15_train.yml
View file @
1b959e3e
...
...
@@ -19,6 +19,7 @@ Global:
max_text_length
:
25
infer_mode
:
False
use_space_char
:
False
save_res_path
:
./output/rec/predicts_ic15.txt
Optimizer
:
name
:
Adam
...
...
configs/rec/rec_mv3_none_bilstm_ctc.yml
View file @
1b959e3e
...
...
@@ -19,6 +19,7 @@ Global:
max_text_length
:
25
infer_mode
:
False
use_space_char
:
False
save_res_path
:
./output/rec/predicts_mv3_none_bilstm_ctc.txt
Optimizer
:
name
:
Adam
...
...
configs/rec/rec_mv3_none_none_ctc.yml
View file @
1b959e3e
...
...
@@ -19,6 +19,7 @@ Global:
max_text_length
:
25
infer_mode
:
False
use_space_char
:
False
save_res_path
:
./output/rec/predicts_mv3_none_none_ctc.txt
Optimizer
:
name
:
Adam
...
...
configs/rec/rec_mv3_tps_bilstm_att.yml
View file @
1b959e3e
...
...
@@ -19,6 +19,7 @@ Global:
max_text_length
:
25
infer_mode
:
False
use_space_char
:
False
save_res_path
:
./output/rec/predicts_mv3_tps_bilstm_att.txt
Optimizer
:
...
...
configs/rec/rec_mv3_tps_bilstm_ctc.yml
View file @
1b959e3e
...
...
@@ -19,6 +19,7 @@ Global:
max_text_length
:
25
infer_mode
:
False
use_space_char
:
False
save_res_path
:
./output/rec/predicts_mv3_tps_bilstm_ctc.txt
Optimizer
:
name
:
Adam
...
...
configs/rec/rec_r34_vd_none_bilstm_ctc.yml
View file @
1b959e3e
...
...
@@ -19,6 +19,7 @@ Global:
max_text_length
:
25
infer_mode
:
False
use_space_char
:
False
save_res_path
:
./output/rec/predicts_r34_vd_none_bilstm_ctc.txt
Optimizer
:
name
:
Adam
...
...
configs/rec/rec_r34_vd_none_none_ctc.yml
View file @
1b959e3e
...
...
@@ -19,6 +19,7 @@ Global:
max_text_length
:
25
infer_mode
:
False
use_space_char
:
False
save_res_path
:
./output/rec/predicts_r34_vd_none_none_ctc.txt
Optimizer
:
name
:
Adam
...
...
configs/rec/rec_r34_vd_tps_bilstm_att.yml
View file @
1b959e3e
...
...
@@ -19,6 +19,7 @@ Global:
max_text_length
:
25
infer_mode
:
False
use_space_char
:
False
save_res_path
:
./output/rec/predicts_b3_rare_r34_none_gru.txt
Optimizer
:
...
...
configs/rec/rec_r34_vd_tps_bilstm_ctc.yml
View file @
1b959e3e
...
...
@@ -19,6 +19,7 @@ Global:
max_text_length
:
25
infer_mode
:
False
use_space_char
:
False
save_res_path
:
./output/rec/predicts_r34_vd_tps_bilstm_ctc.txt
Optimizer
:
name
:
Adam
...
...
configs/rec/rec_r50_fpn_srn.yml
View file @
1b959e3e
...
...
@@ -20,6 +20,7 @@ Global:
num_heads
:
8
infer_mode
:
False
use_space_char
:
False
save_res_path
:
./output/rec/predicts_srn.txt
Optimizer
:
...
...
tools/infer_rec.py
View file @
1b959e3e
...
...
@@ -73,35 +73,45 @@ def main():
global_config
[
'infer_mode'
]
=
True
ops
=
create_operators
(
transforms
,
global_config
)
save_res_path
=
config
[
'Global'
].
get
(
'save_res_path'
,
"./output/rec/predicts_rec.txt"
)
if
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
save_res_path
)):
os
.
makedirs
(
os
.
path
.
dirname
(
save_res_path
))
model
.
eval
()
for
file
in
get_image_file_list
(
config
[
'Global'
][
'infer_img'
]):
logger
.
info
(
"infer_img: {}"
.
format
(
file
))
with
open
(
file
,
'rb'
)
as
f
:
img
=
f
.
read
()
data
=
{
'image'
:
img
}
batch
=
transform
(
data
,
ops
)
if
config
[
'Architecture'
][
'algorithm'
]
==
"SRN"
:
encoder_word_pos_list
=
np
.
expand_dims
(
batch
[
1
],
axis
=
0
)
gsrm_word_pos_list
=
np
.
expand_dims
(
batch
[
2
],
axis
=
0
)
gsrm_slf_attn_bias1_list
=
np
.
expand_dims
(
batch
[
3
],
axis
=
0
)
gsrm_slf_attn_bias2_list
=
np
.
expand_dims
(
batch
[
4
],
axis
=
0
)
others
=
[
paddle
.
to_tensor
(
encoder_word_pos_list
),
paddle
.
to_tensor
(
gsrm_word_pos_list
),
paddle
.
to_tensor
(
gsrm_slf_attn_bias1_list
),
paddle
.
to_tensor
(
gsrm_slf_attn_bias2_list
)
]
images
=
np
.
expand_dims
(
batch
[
0
],
axis
=
0
)
images
=
paddle
.
to_tensor
(
images
)
if
config
[
'Architecture'
][
'algorithm'
]
==
"SRN"
:
preds
=
model
(
images
,
others
)
else
:
preds
=
model
(
images
)
post_result
=
post_process_class
(
preds
)
for
rec_reuslt
in
post_result
:
logger
.
info
(
'
\t
result: {}'
.
format
(
rec_reuslt
))
with
open
(
save_res_path
,
"w"
)
as
fout
:
for
file
in
get_image_file_list
(
config
[
'Global'
][
'infer_img'
]):
logger
.
info
(
"infer_img: {}"
.
format
(
file
))
with
open
(
file
,
'rb'
)
as
f
:
img
=
f
.
read
()
data
=
{
'image'
:
img
}
batch
=
transform
(
data
,
ops
)
if
config
[
'Architecture'
][
'algorithm'
]
==
"SRN"
:
encoder_word_pos_list
=
np
.
expand_dims
(
batch
[
1
],
axis
=
0
)
gsrm_word_pos_list
=
np
.
expand_dims
(
batch
[
2
],
axis
=
0
)
gsrm_slf_attn_bias1_list
=
np
.
expand_dims
(
batch
[
3
],
axis
=
0
)
gsrm_slf_attn_bias2_list
=
np
.
expand_dims
(
batch
[
4
],
axis
=
0
)
others
=
[
paddle
.
to_tensor
(
encoder_word_pos_list
),
paddle
.
to_tensor
(
gsrm_word_pos_list
),
paddle
.
to_tensor
(
gsrm_slf_attn_bias1_list
),
paddle
.
to_tensor
(
gsrm_slf_attn_bias2_list
)
]
images
=
np
.
expand_dims
(
batch
[
0
],
axis
=
0
)
images
=
paddle
.
to_tensor
(
images
)
if
config
[
'Architecture'
][
'algorithm'
]
==
"SRN"
:
preds
=
model
(
images
,
others
)
else
:
preds
=
model
(
images
)
post_result
=
post_process_class
(
preds
)
for
rec_reuslt
in
post_result
:
logger
.
info
(
'
\t
result: {}'
.
format
(
rec_reuslt
))
if
len
(
rec_reuslt
)
>=
2
:
fout
.
write
(
file
+
"
\t
"
+
rec_reuslt
[
0
]
+
"
\t
"
+
str
(
rec_reuslt
[
1
])
+
"
\n
"
)
logger
.
info
(
"success!"
)
...
...
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