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
cffb0316
Unverified
Commit
cffb0316
authored
Feb 07, 2022
by
zhoujun
Committed by
GitHub
Feb 07, 2022
Browse files
Merge pull request #5392 from littletomatodonkey/dyg/add_system_save
add system pred save
parents
c9d7ec85
417f76b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
tools/infer/predict_system.py
tools/infer/predict_system.py
+15
-2
No files found.
tools/infer/predict_system.py
View file @
cffb0316
...
@@ -24,6 +24,7 @@ os.environ["FLAGS_allocator_strategy"] = 'auto_growth'
...
@@ -24,6 +24,7 @@ os.environ["FLAGS_allocator_strategy"] = 'auto_growth'
import
cv2
import
cv2
import
copy
import
copy
import
numpy
as
np
import
numpy
as
np
import
json
import
time
import
time
import
logging
import
logging
from
PIL
import
Image
from
PIL
import
Image
...
@@ -128,6 +129,9 @@ def main(args):
...
@@ -128,6 +129,9 @@ def main(args):
is_visualize
=
True
is_visualize
=
True
font_path
=
args
.
vis_font_path
font_path
=
args
.
vis_font_path
drop_score
=
args
.
drop_score
drop_score
=
args
.
drop_score
draw_img_save_dir
=
args
.
draw_img_save_dir
os
.
makedirs
(
draw_img_save_dir
,
exist_ok
=
True
)
save_results
=
[]
# warm up 10 times
# warm up 10 times
if
args
.
warmup
:
if
args
.
warmup
:
...
@@ -157,6 +161,14 @@ def main(args):
...
@@ -157,6 +161,14 @@ def main(args):
for
text
,
score
in
rec_res
:
for
text
,
score
in
rec_res
:
logger
.
debug
(
"{}, {:.3f}"
.
format
(
text
,
score
))
logger
.
debug
(
"{}, {:.3f}"
.
format
(
text
,
score
))
res
=
[{
"transcription"
:
rec_res
[
idx
][
0
],
"points"
:
np
.
array
(
dt_boxes
[
idx
]).
astype
(
np
.
int32
).
tolist
(),
}
for
idx
in
range
(
len
(
dt_boxes
))]
save_pred
=
os
.
path
.
basename
(
image_file
)
+
"
\t
"
+
json
.
dumps
(
res
,
ensure_ascii
=
False
)
+
"
\n
"
save_results
.
append
(
save_pred
)
if
is_visualize
:
if
is_visualize
:
image
=
Image
.
fromarray
(
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2RGB
))
image
=
Image
.
fromarray
(
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2RGB
))
boxes
=
dt_boxes
boxes
=
dt_boxes
...
@@ -170,8 +182,6 @@ def main(args):
...
@@ -170,8 +182,6 @@ def main(args):
scores
,
scores
,
drop_score
=
drop_score
,
drop_score
=
drop_score
,
font_path
=
font_path
)
font_path
=
font_path
)
draw_img_save_dir
=
args
.
draw_img_save_dir
os
.
makedirs
(
draw_img_save_dir
,
exist_ok
=
True
)
if
flag
:
if
flag
:
image_file
=
image_file
[:
-
3
]
+
"png"
image_file
=
image_file
[:
-
3
]
+
"png"
cv2
.
imwrite
(
cv2
.
imwrite
(
...
@@ -185,6 +195,9 @@ def main(args):
...
@@ -185,6 +195,9 @@ def main(args):
text_sys
.
text_detector
.
autolog
.
report
()
text_sys
.
text_detector
.
autolog
.
report
()
text_sys
.
text_recognizer
.
autolog
.
report
()
text_sys
.
text_recognizer
.
autolog
.
report
()
with
open
(
os
.
path
.
join
(
draw_img_save_dir
,
"system_results.txt"
),
'w'
)
as
f
:
f
.
writelines
(
save_results
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
args
=
utility
.
parse_args
()
args
=
utility
.
parse_args
()
...
...
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