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
05dcfdec
Commit
05dcfdec
authored
Nov 27, 2020
by
WenmuZhou
Browse files
Fix the bug that the predict time is calculated incorrectly
parent
606a3873
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
tools/infer/predict_cls.py
tools/infer/predict_cls.py
+5
-5
tools/infer/predict_rec.py
tools/infer/predict_rec.py
+1
-1
No files found.
tools/infer/predict_cls.py
View file @
05dcfdec
...
@@ -82,7 +82,7 @@ class TextClassifier(object):
...
@@ -82,7 +82,7 @@ class TextClassifier(object):
cls_res
=
[[
''
,
0.0
]]
*
img_num
cls_res
=
[[
''
,
0.0
]]
*
img_num
batch_num
=
self
.
cls_batch_num
batch_num
=
self
.
cls_batch_num
predict_tim
e
=
0
elaps
e
=
0
for
beg_img_no
in
range
(
0
,
img_num
,
batch_num
):
for
beg_img_no
in
range
(
0
,
img_num
,
batch_num
):
end_img_no
=
min
(
img_num
,
beg_img_no
+
batch_num
)
end_img_no
=
min
(
img_num
,
beg_img_no
+
batch_num
)
norm_img_batch
=
[]
norm_img_batch
=
[]
...
@@ -107,14 +107,14 @@ class TextClassifier(object):
...
@@ -107,14 +107,14 @@ class TextClassifier(object):
self
.
predictor
.
run
([
norm_img_batch
])
self
.
predictor
.
run
([
norm_img_batch
])
prob_out
=
self
.
output_tensors
[
0
].
copy_to_cpu
()
prob_out
=
self
.
output_tensors
[
0
].
copy_to_cpu
()
cls_res
=
self
.
postprocess_op
(
prob_out
)
cls_res
=
self
.
postprocess_op
(
prob_out
)
elapse
=
time
.
time
()
-
starttime
elapse
+
=
time
.
time
()
-
starttime
for
rno
in
range
(
len
(
cls_res
)):
for
rno
in
range
(
len
(
cls_res
)):
label
,
score
=
cls_res
[
rno
]
label
,
score
=
cls_res
[
rno
]
cls_res
[
indices
[
beg_img_no
+
rno
]]
=
[
label
,
score
]
cls_res
[
indices
[
beg_img_no
+
rno
]]
=
[
label
,
score
]
if
'180'
in
label
and
score
>
self
.
cls_thresh
:
if
'180'
in
label
and
score
>
self
.
cls_thresh
:
img_list
[
indices
[
beg_img_no
+
rno
]]
=
cv2
.
rotate
(
img_list
[
indices
[
beg_img_no
+
rno
]]
=
cv2
.
rotate
(
img_list
[
indices
[
beg_img_no
+
rno
]],
1
)
img_list
[
indices
[
beg_img_no
+
rno
]],
1
)
return
img_list
,
cls_res
,
predict_tim
e
return
img_list
,
cls_res
,
elaps
e
def
main
(
args
):
def
main
(
args
):
...
@@ -132,7 +132,7 @@ def main(args):
...
@@ -132,7 +132,7 @@ def main(args):
valid_image_file_list
.
append
(
image_file
)
valid_image_file_list
.
append
(
image_file
)
img_list
.
append
(
img
)
img_list
.
append
(
img
)
try
:
try
:
img_list
,
cls_res
,
predict_tim
e
=
text_classifier
(
img_list
)
img_list
,
cls_res
,
elaps
e
=
text_classifier
(
img_list
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
e
)
print
(
e
)
logger
.
info
(
logger
.
info
(
...
@@ -145,7 +145,7 @@ def main(args):
...
@@ -145,7 +145,7 @@ def main(args):
for
ino
in
range
(
len
(
img_list
)):
for
ino
in
range
(
len
(
img_list
)):
print
(
"Predicts of %s:%s"
%
(
valid_image_file_list
[
ino
],
cls_res
[
ino
]))
print
(
"Predicts of %s:%s"
%
(
valid_image_file_list
[
ino
],
cls_res
[
ino
]))
print
(
"Total predict time for %d images, cost: %.3f"
%
print
(
"Total predict time for %d images, cost: %.3f"
%
(
len
(
img_list
),
predict_tim
e
))
(
len
(
img_list
),
elaps
e
))
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
tools/infer/predict_rec.py
View file @
05dcfdec
...
@@ -115,7 +115,7 @@ class TextRecognizer(object):
...
@@ -115,7 +115,7 @@ class TextRecognizer(object):
rec_result
=
self
.
postprocess_op
(
preds
)
rec_result
=
self
.
postprocess_op
(
preds
)
for
rno
in
range
(
len
(
rec_result
)):
for
rno
in
range
(
len
(
rec_result
)):
rec_res
[
indices
[
beg_img_no
+
rno
]]
=
rec_result
[
rno
]
rec_res
[
indices
[
beg_img_no
+
rno
]]
=
rec_result
[
rno
]
elapse
=
time
.
time
()
-
starttime
elapse
+
=
time
.
time
()
-
starttime
return
rec_res
,
elapse
return
rec_res
,
elapse
...
...
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