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
ea60a034
"git@developer.sourcefind.cn:wangsen/paddle_dbnet.git" did not exist on "cf550d052469e11bff6d1d88a9e473c45df5d21e"
Commit
ea60a034
authored
Jun 24, 2021
by
LDOUBLEV
Browse files
enhance auto_log
parent
01c4ee5d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
1 deletion
+29
-1
tools/infer/predict_det.py
tools/infer/predict_det.py
+29
-1
No files found.
tools/infer/predict_det.py
View file @
ea60a034
...
...
@@ -34,6 +34,7 @@ from ppocr.postprocess import build_post_process
# import tools.infer.benchmark_utils as benchmark_utils
logger
=
get_logger
()
import
auto_log
class
TextDetector
(
object
):
...
...
@@ -100,6 +101,22 @@ class TextDetector(object):
self
.
predictor
,
self
.
input_tensor
,
self
.
output_tensors
,
self
.
config
=
utility
.
create_predictor
(
args
,
'det'
,
logger
)
pid
=
os
.
getpid
()
self
.
autolog
=
auto_log
.
AutoLogger
(
model_name
=
"det"
,
model_precision
=
"fp32"
,
batch_size
=
1
,
data_shape
=
"dynamic"
,
save_path
=
"./output/auto_log.lpg"
,
inference_config
=
self
.
config
,
pids
=
pid
,
process_name
=
None
,
gpu_ids
=
0
,
time_keys
=
[
'preprocess_time'
,
'inference_time'
,
'postprocess_time'
],
warmup
=
10
)
def
order_points_clockwise
(
self
,
pts
):
"""
reference from: https://github.com/jrosebr1/imutils/blob/master/imutils/perspective.py
...
...
@@ -158,6 +175,9 @@ class TextDetector(object):
data
=
{
'image'
:
img
}
st
=
time
.
time
()
self
.
autolog
.
times
.
start
()
data
=
transform
(
data
,
self
.
preprocess_op
)
img
,
shape_list
=
data
if
img
is
None
:
...
...
@@ -166,6 +186,8 @@ class TextDetector(object):
shape_list
=
np
.
expand_dims
(
shape_list
,
axis
=
0
)
img
=
img
.
copy
()
self
.
autolog
.
times
.
stamp
()
self
.
input_tensor
.
copy_from_cpu
(
img
)
self
.
predictor
.
run
()
outputs
=
[]
...
...
@@ -173,6 +195,8 @@ class TextDetector(object):
output
=
output_tensor
.
copy_to_cpu
()
outputs
.
append
(
output
)
self
.
autolog
.
times
.
stamp
()
preds
=
{}
if
self
.
det_algorithm
==
"EAST"
:
preds
[
'f_geo'
]
=
outputs
[
0
]
...
...
@@ -195,7 +219,9 @@ class TextDetector(object):
else
:
dt_boxes
=
self
.
filter_tag_det_res
(
dt_boxes
,
ori_im
.
shape
)
self
.
autolog
.
times
.
end
(
stamp
=
True
)
et
=
time
.
time
()
self
.
autolog
.
get_avg_mem_mb
()
return
dt_boxes
,
et
-
st
...
...
@@ -212,7 +238,7 @@ if __name__ == "__main__":
for
i
in
range
(
10
):
res
=
text_detector
(
img
)
cpu_mem
,
gpu_mem
,
gpu_util
=
0
,
0
,
0
text_detector
.
autolog
.
mem_info
.
_start_subprocess
()
if
not
os
.
path
.
exists
(
draw_img_save
):
os
.
makedirs
(
draw_img_save
)
...
...
@@ -237,3 +263,5 @@ if __name__ == "__main__":
"det_res_{}"
.
format
(
img_name_pure
))
logger
.
info
(
"The visualized image saved in {}"
.
format
(
img_path
))
text_detector
.
autolog
.
report
()
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