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
1e9683b4
Commit
1e9683b4
authored
May 15, 2020
by
LDOUBLEV
Browse files
add visualized code for det results
parent
5c043e5b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
tools/infer/predict_det.py
tools/infer/predict_det.py
+7
-3
tools/infer/utility.py
tools/infer/utility.py
+2
-3
No files found.
tools/infer/predict_det.py
View file @
1e9683b4
...
...
@@ -153,6 +153,8 @@ class TextDetector(object):
return
dt_boxes
,
elapse
from
tools.infer.utility
import
draw_text_det_res
if
__name__
==
"__main__"
:
args
=
utility
.
parse_args
()
image_file_list
=
get_image_file_list
(
args
.
image_dir
)
...
...
@@ -169,7 +171,9 @@ if __name__ == "__main__":
total_time
+=
elapse
count
+=
1
print
(
"Predict time of %s:"
%
image_file
,
elapse
)
"""
add visualized code
"""
img_draw
=
draw_text_det_res
(
dt_boxes
,
image_file
,
return_img
=
True
)
save_path
=
os
.
path
.
join
(
"./inference_det/"
,
os
.
path
.
basename
(
image_file
))
print
(
"The visualized image saved in {}"
.
format
(
save_path
))
print
(
"Avg Time:"
,
total_time
/
(
count
-
1
))
tools/infer/utility.py
View file @
1e9683b4
...
...
@@ -103,13 +103,12 @@ def create_predictor(args, mode):
return
predictor
,
input_tensor
,
output_tensors
def
draw_text_det_res
(
dt_boxes
,
img_path
):
def
draw_text_det_res
(
dt_boxes
,
img_path
,
return_img
=
True
):
src_im
=
cv2
.
imread
(
img_path
)
for
box
in
dt_boxes
:
box
=
np
.
array
(
box
).
astype
(
np
.
int32
).
reshape
(
-
1
,
2
)
cv2
.
polylines
(
src_im
,
[
box
],
True
,
color
=
(
255
,
255
,
0
),
thickness
=
2
)
img_name_pure
=
img_path
.
split
(
"/"
)[
-
1
]
cv2
.
imwrite
(
"./output/%s"
%
img_name_pure
,
src_im
)
return
src_im
def
resize_img
(
img
,
input_size
=
600
):
...
...
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