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
ModelZoo
SOLOv2-pytorch
Commits
be36de16
Commit
be36de16
authored
Nov 17, 2020
by
edwardxliu
Browse files
fix streaming issue
parent
0b0dfb34
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
demo/webcam_demo.py
demo/webcam_demo.py
+3
-3
mmdet/apis/inference.py
mmdet/apis/inference.py
+4
-2
No files found.
demo/webcam_demo.py
View file @
be36de16
...
@@ -3,7 +3,7 @@ import argparse
...
@@ -3,7 +3,7 @@ import argparse
import
cv2
import
cv2
import
torch
import
torch
from
mmdet.apis
import
inference_detector
,
init_detector
,
show_result
from
mmdet.apis
import
inference_detector
,
init_detector
,
show_result
,
show_result_ins
def
parse_args
():
def
parse_args
():
...
@@ -36,8 +36,8 @@ def main():
...
@@ -36,8 +36,8 @@ def main():
if
ch
==
27
or
ch
==
ord
(
'q'
)
or
ch
==
ord
(
'Q'
):
if
ch
==
27
or
ch
==
ord
(
'q'
)
or
ch
==
ord
(
'Q'
):
break
break
show_result
(
img_show
=
show_result_ins
(
img
,
result
,
model
.
CLASSES
,
score_thr
=
0.25
)
img
,
result
,
model
.
CLASSES
,
score_thr
=
args
.
score_thr
,
wait_time
=
1
)
cv2
.
imshow
(
'Demo'
,
img_show
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
mmdet/apis/inference.py
View file @
be36de16
...
@@ -227,12 +227,14 @@ def show_result_ins(img,
...
@@ -227,12 +227,14 @@ def show_result_ins(img,
np.ndarray or None: If neither `show` nor `out_file` is specified, the
np.ndarray or None: If neither `show` nor `out_file` is specified, the
visualized image is returned, otherwise None is returned.
visualized image is returned, otherwise None is returned.
"""
"""
assert
isinstance
(
class_names
,
(
tuple
,
list
))
assert
isinstance
(
class_names
,
(
tuple
,
list
))
img
=
mmcv
.
imread
(
img
)
img
=
mmcv
.
imread
(
img
)
img_show
=
img
.
copy
()
img_show
=
img
.
copy
()
h
,
w
,
_
=
img
.
shape
h
,
w
,
_
=
img
.
shape
if
not
result
or
result
==
[
None
]:
return
img_show
cur_result
=
result
[
0
]
cur_result
=
result
[
0
]
seg_label
=
cur_result
[
0
]
seg_label
=
cur_result
[
0
]
seg_label
=
seg_label
.
cpu
().
numpy
().
astype
(
np
.
uint8
)
seg_label
=
seg_label
.
cpu
().
numpy
().
astype
(
np
.
uint8
)
...
@@ -283,6 +285,6 @@ def show_result_ins(img,
...
@@ -283,6 +285,6 @@ def show_result_ins(img,
cv2
.
putText
(
img_show
,
label_text
,
vis_pos
,
cv2
.
putText
(
img_show
,
label_text
,
vis_pos
,
cv2
.
FONT_HERSHEY_COMPLEX
,
0.3
,
(
255
,
255
,
255
))
# green
cv2
.
FONT_HERSHEY_COMPLEX
,
0.3
,
(
255
,
255
,
255
))
# green
if
out_file
is
None
:
if
out_file
is
None
:
return
img
return
img
_show
else
:
else
:
mmcv
.
imwrite
(
img_show
,
out_file
)
mmcv
.
imwrite
(
img_show
,
out_file
)
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