From 6371de8879e7ad7ec5283e8b95cc6dd85d6a5e72 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 18 Oct 2022 22:26:53 +0200 Subject: [PATCH] Webcam show fix (#9847) * Webcam show fix Signed-off-by: Glenn Jocher * Update common.py Signed-off-by: Glenn Jocher * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: Glenn Jocher Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- models/common.py | 8 +++----- utils/general.py | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/models/common.py b/models/common.py index e6da429de3e5..ba18cbce7429 100644 --- a/models/common.py +++ b/models/common.py @@ -24,14 +24,12 @@ from utils import TryExcept from utils.dataloaders import exif_transpose, letterbox -from utils.general import (LOGGER, ROOT, Profile, check_imshow, check_requirements, check_suffix, check_version, - colorstr, increment_path, make_divisible, non_max_suppression, scale_boxes, xywh2xyxy, +from utils.general import (LOGGER, ROOT, Profile, check_requirements, check_suffix, check_version, colorstr, + increment_path, is_notebook, make_divisible, non_max_suppression, scale_boxes, xywh2xyxy, xyxy2xywh, yaml_load) from utils.plots import Annotator, colors, save_one_box from utils.torch_utils import copy_attr, smart_inference_mode -CHECK_IMSHOW = check_imshow() - def autopad(k, p=None, d=1): # kernel, padding, dilation # Pad to 'same' shape outputs @@ -760,7 +758,7 @@ def _run(self, pprint=False, show=False, save=False, crop=False, render=False, l im = Image.fromarray(im.astype(np.uint8)) if isinstance(im, np.ndarray) else im # from np if show: - im.show(self.files[i]) if CHECK_IMSHOW else display(im) + display(im) if is_notebook() else im.show(self.files[i]) if save: f = self.files[i] im.save(save_dir / f) # save diff --git a/utils/general.py b/utils/general.py index fb8484ce434e..e1823b50ac56 100644 --- a/utils/general.py +++ b/utils/general.py @@ -395,7 +395,6 @@ def check_imshow(warn=False): try: assert not is_notebook() assert not is_docker() - assert 'NoneType' not in str(type(IPython.get_ipython())) # SSH terminals, GitHub CI cv2.imshow('test', np.zeros((1, 1, 3))) cv2.waitKey(1) cv2.destroyAllWindows()