Skip to content

Commit 6371de8

Browse files
Webcam show fix (#9847)
* Webcam show fix Signed-off-by: Glenn Jocher <[email protected]> * Update common.py Signed-off-by: Glenn Jocher <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: Glenn Jocher <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent c471001 commit 6371de8

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

models/common.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@
2424

2525
from utils import TryExcept
2626
from utils.dataloaders import exif_transpose, letterbox
27-
from utils.general import (LOGGER, ROOT, Profile, check_imshow, check_requirements, check_suffix, check_version,
28-
colorstr, increment_path, make_divisible, non_max_suppression, scale_boxes, xywh2xyxy,
27+
from utils.general import (LOGGER, ROOT, Profile, check_requirements, check_suffix, check_version, colorstr,
28+
increment_path, is_notebook, make_divisible, non_max_suppression, scale_boxes, xywh2xyxy,
2929
xyxy2xywh, yaml_load)
3030
from utils.plots import Annotator, colors, save_one_box
3131
from utils.torch_utils import copy_attr, smart_inference_mode
3232

33-
CHECK_IMSHOW = check_imshow()
34-
3533

3634
def autopad(k, p=None, d=1): # kernel, padding, dilation
3735
# Pad to 'same' shape outputs
@@ -760,7 +758,7 @@ def _run(self, pprint=False, show=False, save=False, crop=False, render=False, l
760758

761759
im = Image.fromarray(im.astype(np.uint8)) if isinstance(im, np.ndarray) else im # from np
762760
if show:
763-
im.show(self.files[i]) if CHECK_IMSHOW else display(im)
761+
display(im) if is_notebook() else im.show(self.files[i])
764762
if save:
765763
f = self.files[i]
766764
im.save(save_dir / f) # save

utils/general.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ def check_imshow(warn=False):
395395
try:
396396
assert not is_notebook()
397397
assert not is_docker()
398-
assert 'NoneType' not in str(type(IPython.get_ipython())) # SSH terminals, GitHub CI
399398
cv2.imshow('test', np.zeros((1, 1, 3)))
400399
cv2.waitKey(1)
401400
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)