Commit be36de16 authored by edwardxliu's avatar edwardxliu
Browse files

fix streaming issue

parent 0b0dfb34
......@@ -3,7 +3,7 @@ import argparse
import cv2
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():
......@@ -36,8 +36,8 @@ def main():
if ch == 27 or ch == ord('q') or ch == ord('Q'):
break
show_result(
img, result, model.CLASSES, score_thr=args.score_thr, wait_time=1)
img_show = show_result_ins(img, result, model.CLASSES, score_thr=0.25)
cv2.imshow('Demo', img_show)
if __name__ == '__main__':
......
......@@ -227,12 +227,14 @@ def show_result_ins(img,
np.ndarray or None: If neither `show` nor `out_file` is specified, the
visualized image is returned, otherwise None is returned.
"""
assert isinstance(class_names, (tuple, list))
img = mmcv.imread(img)
img_show = img.copy()
h, w, _ = img.shape
if not result or result == [None]:
return img_show
cur_result = result[0]
seg_label = cur_result[0]
seg_label = seg_label.cpu().numpy().astype(np.uint8)
......@@ -283,6 +285,6 @@ def show_result_ins(img,
cv2.putText(img_show, label_text, vis_pos,
cv2.FONT_HERSHEY_COMPLEX, 0.3, (255, 255, 255)) # green
if out_file is None:
return img
return img_show
else:
mmcv.imwrite(img_show, out_file)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment