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
7c43db14
Unverified
Commit
7c43db14
authored
Aug 18, 2021
by
Double_V
Committed by
GitHub
Aug 18, 2021
Browse files
Merge pull request #3710 from LDOUBLEV/fix_tests
add gpu check
parents
a81b88a0
49c4a3a7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
2 deletions
+18
-2
tools/infer/predict_det.py
tools/infer/predict_det.py
+2
-1
tools/infer/predict_rec.py
tools/infer/predict_rec.py
+2
-1
tools/infer/utility.py
tools/infer/utility.py
+14
-0
No files found.
tools/infer/predict_det.py
View file @
7c43db14
...
@@ -101,6 +101,7 @@ class TextDetector(object):
...
@@ -101,6 +101,7 @@ class TextDetector(object):
if
args
.
benchmark
:
if
args
.
benchmark
:
import
auto_log
import
auto_log
pid
=
os
.
getpid
()
pid
=
os
.
getpid
()
gpu_id
=
utility
.
get_infer_gpuid
()
self
.
autolog
=
auto_log
.
AutoLogger
(
self
.
autolog
=
auto_log
.
AutoLogger
(
model_name
=
"det"
,
model_name
=
"det"
,
model_precision
=
args
.
precision
,
model_precision
=
args
.
precision
,
...
@@ -110,7 +111,7 @@ class TextDetector(object):
...
@@ -110,7 +111,7 @@ class TextDetector(object):
inference_config
=
self
.
config
,
inference_config
=
self
.
config
,
pids
=
pid
,
pids
=
pid
,
process_name
=
None
,
process_name
=
None
,
gpu_ids
=
0
,
gpu_ids
=
gpu_id
if
args
.
use_gpu
else
None
,
time_keys
=
[
time_keys
=
[
'preprocess_time'
,
'inference_time'
,
'postprocess_time'
'preprocess_time'
,
'inference_time'
,
'postprocess_time'
],
],
...
...
tools/infer/predict_rec.py
View file @
7c43db14
...
@@ -68,6 +68,7 @@ class TextRecognizer(object):
...
@@ -68,6 +68,7 @@ class TextRecognizer(object):
if
args
.
benchmark
:
if
args
.
benchmark
:
import
auto_log
import
auto_log
pid
=
os
.
getpid
()
pid
=
os
.
getpid
()
gpu_id
=
utility
.
get_infer_gpuid
()
self
.
autolog
=
auto_log
.
AutoLogger
(
self
.
autolog
=
auto_log
.
AutoLogger
(
model_name
=
"rec"
,
model_name
=
"rec"
,
model_precision
=
args
.
precision
,
model_precision
=
args
.
precision
,
...
@@ -77,7 +78,7 @@ class TextRecognizer(object):
...
@@ -77,7 +78,7 @@ class TextRecognizer(object):
inference_config
=
self
.
config
,
inference_config
=
self
.
config
,
pids
=
pid
,
pids
=
pid
,
process_name
=
None
,
process_name
=
None
,
gpu_ids
=
0
if
args
.
use_gpu
else
None
,
gpu_ids
=
gpu_id
if
args
.
use_gpu
else
None
,
time_keys
=
[
time_keys
=
[
'preprocess_time'
,
'inference_time'
,
'postprocess_time'
'preprocess_time'
,
'inference_time'
,
'postprocess_time'
],
],
...
...
tools/infer/utility.py
View file @
7c43db14
...
@@ -280,6 +280,20 @@ def create_predictor(args, mode, logger):
...
@@ -280,6 +280,20 @@ def create_predictor(args, mode, logger):
return
predictor
,
input_tensor
,
output_tensors
,
config
return
predictor
,
input_tensor
,
output_tensors
,
config
def
get_infer_gpuid
():
cmd
=
"nvidia-smi"
res
=
os
.
popen
(
cmd
).
readlines
()
if
len
(
res
)
==
0
:
return
None
cmd
=
"env | grep CUDA_VISIBLE_DEVICES"
env_cuda
=
os
.
popen
(
cmd
).
readlines
()
if
len
(
env_cuda
)
==
0
:
return
0
else
:
gpu_id
=
env_cuda
[
0
].
strip
().
split
(
"="
)[
1
]
return
int
(
gpu_id
[
0
])
def
draw_e2e_res
(
dt_boxes
,
strs
,
img_path
):
def
draw_e2e_res
(
dt_boxes
,
strs
,
img_path
):
src_im
=
cv2
.
imread
(
img_path
)
src_im
=
cv2
.
imread
(
img_path
)
for
box
,
str
in
zip
(
dt_boxes
,
strs
):
for
box
,
str
in
zip
(
dt_boxes
,
strs
):
...
...
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