From e2c1014d818cf433ed6c6ca1d9cbd41405f9a2cc Mon Sep 17 00:00:00 2001 From: Nicholas Zolton Date: Fri, 24 Jun 2022 10:03:34 -0500 Subject: [PATCH 1/2] fixed initial window size of detect.py being tiny --- detect.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/detect.py b/detect.py index 9d92e4c169e4..87e41ca801e7 100644 --- a/detect.py +++ b/detect.py @@ -107,6 +107,7 @@ def run( # Run inference model.warmup(imgsz=(1 if pt else bs, 3, *imgsz)) # warmup dt, seen = [0.0, 0.0, 0.0], 0 + open_windows = [] for path, im, im0s, vid_cap, s in dataset: t1 = time_sync() im = torch.from_numpy(im).to(device) @@ -173,7 +174,10 @@ def run( # Stream results im0 = annotator.result() if view_img: - cv2.namedWindow(str(p), cv2.WINDOW_NORMAL | cv2.WINDOW_KEEPRATIO) # allow window resize (Linux) + if p not in open_windows: + open_windows.append(p) + cv2.namedWindow(str(p), cv2.WINDOW_NORMAL | cv2.WINDOW_KEEPRATIO) # allow window resize (Linux) + cv2.resizeWindow(str(p), im0.shape[1], im0.shape[0]) cv2.imshow(str(p), im0) cv2.waitKey(1) # 1 millisecond From 0c894cf9a53b678fc17b5d6ac35f326927d18b7f Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 26 Jun 2022 23:56:46 +0200 Subject: [PATCH 2/2] cleanup --- detect.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/detect.py b/detect.py index 87e41ca801e7..bb09ce171a96 100644 --- a/detect.py +++ b/detect.py @@ -106,8 +106,7 @@ def run( # Run inference model.warmup(imgsz=(1 if pt else bs, 3, *imgsz)) # warmup - dt, seen = [0.0, 0.0, 0.0], 0 - open_windows = [] + seen, windows, dt = 0, [], [0.0, 0.0, 0.0] for path, im, im0s, vid_cap, s in dataset: t1 = time_sync() im = torch.from_numpy(im).to(device) @@ -174,8 +173,8 @@ def run( # Stream results im0 = annotator.result() if view_img: - if p not in open_windows: - open_windows.append(p) + if p not in windows: + windows.append(p) cv2.namedWindow(str(p), cv2.WINDOW_NORMAL | cv2.WINDOW_KEEPRATIO) # allow window resize (Linux) cv2.resizeWindow(str(p), im0.shape[1], im0.shape[0]) cv2.imshow(str(p), im0)