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
bd1820b7
Commit
bd1820b7
authored
Jun 05, 2021
by
littletomatodonkey
Browse files
fix infer rec
parent
115955f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
6 deletions
+20
-6
configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_distillation_v2.1.yml
...h_ppocr_v2.0/rec_chinese_lite_train_distillation_v2.1.yml
+2
-1
tools/infer_rec.py
tools/infer_rec.py
+18
-5
No files found.
configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_distillation_v2.1.yml
View file @
bd1820b7
...
@@ -19,6 +19,7 @@ Global:
...
@@ -19,6 +19,7 @@ Global:
infer_mode
:
false
infer_mode
:
false
use_space_char
:
false
use_space_char
:
false
distributed
:
true
distributed
:
true
save_res_path
:
./output/rec/predicts_chinese_lite_distillation_v2.1.txt
Optimizer
:
Optimizer
:
...
@@ -98,7 +99,7 @@ Loss:
...
@@ -98,7 +99,7 @@ Loss:
PostProcess
:
PostProcess
:
name
:
DistillationCTCLabelDecode
name
:
DistillationCTCLabelDecode
model_name
:
[
"
Student"
]
model_name
:
[
"
Student"
,
"
Teacher"
]
key
:
head_out
key
:
head_out
Metric
:
Metric
:
...
...
tools/infer_rec.py
View file @
bd1820b7
...
@@ -20,6 +20,7 @@ import numpy as np
...
@@ -20,6 +20,7 @@ import numpy as np
import
os
import
os
import
sys
import
sys
import
json
__dir__
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
__dir__
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
sys
.
path
.
append
(
__dir__
)
sys
.
path
.
append
(
__dir__
)
...
@@ -113,11 +114,23 @@ def main():
...
@@ -113,11 +114,23 @@ def main():
else
:
else
:
preds
=
model
(
images
)
preds
=
model
(
images
)
post_result
=
post_process_class
(
preds
)
post_result
=
post_process_class
(
preds
)
for
rec_reuslt
in
post_result
:
info
=
None
logger
.
info
(
'
\t
result: {}'
.
format
(
rec_reuslt
))
if
isinstance
(
post_result
,
dict
):
if
len
(
rec_reuslt
)
>=
2
:
rec_info
=
dict
()
fout
.
write
(
file
+
"
\t
"
+
rec_reuslt
[
0
]
+
"
\t
"
+
str
(
for
key
in
post_result
:
rec_reuslt
[
1
])
+
"
\n
"
)
if
len
(
post_result
[
key
][
0
])
>=
2
:
rec_info
[
key
]
=
{
"label"
:
post_result
[
key
][
0
][
0
],
"score"
:
post_result
[
key
][
0
][
1
],
}
info
=
json
.
dumps
(
rec_info
)
else
:
if
len
(
post_result
[
0
])
>=
2
:
info
=
post_result
[
0
][
0
]
+
"
\t
"
+
str
(
post_result
[
0
][
1
])
if
info
is
not
None
:
logger
.
info
(
"
\t
result: {}"
.
format
(
info
))
fout
.
write
(
file
+
"
\t
"
+
info
)
logger
.
info
(
"success!"
)
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