Unverified 提交 6371de88 authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Webcam show fix (#9847)

* Webcam show fix Signed-off-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com> * Update common.py Signed-off-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ciSigned-off-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: 's avatarpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
上级 c4710012
...@@ -24,14 +24,12 @@ from torch.cuda import amp ...@@ -24,14 +24,12 @@ from torch.cuda import amp
from utils import TryExcept from utils import TryExcept
from utils.dataloaders import exif_transpose, letterbox from utils.dataloaders import exif_transpose, letterbox
from utils.general import (LOGGER, ROOT, Profile, check_imshow, check_requirements, check_suffix, check_version, from utils.general import (LOGGER, ROOT, Profile, check_requirements, check_suffix, check_version, colorstr,
colorstr, increment_path, make_divisible, non_max_suppression, scale_boxes, xywh2xyxy, increment_path, is_notebook, make_divisible, non_max_suppression, scale_boxes, xywh2xyxy,
xyxy2xywh, yaml_load) xyxy2xywh, yaml_load)
from utils.plots import Annotator, colors, save_one_box from utils.plots import Annotator, colors, save_one_box
from utils.torch_utils import copy_attr, smart_inference_mode from utils.torch_utils import copy_attr, smart_inference_mode
CHECK_IMSHOW = check_imshow()
def autopad(k, p=None, d=1): # kernel, padding, dilation def autopad(k, p=None, d=1): # kernel, padding, dilation
# Pad to 'same' shape outputs # Pad to 'same' shape outputs
...@@ -760,7 +758,7 @@ class Detections: ...@@ -760,7 +758,7 @@ class Detections:
im = Image.fromarray(im.astype(np.uint8)) if isinstance(im, np.ndarray) else im # from np im = Image.fromarray(im.astype(np.uint8)) if isinstance(im, np.ndarray) else im # from np
if show: 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: if save:
f = self.files[i] f = self.files[i]
im.save(save_dir / f) # save im.save(save_dir / f) # save
......
...@@ -395,7 +395,6 @@ def check_imshow(warn=False): ...@@ -395,7 +395,6 @@ def check_imshow(warn=False):
try: try:
assert not is_notebook() assert not is_notebook()
assert not is_docker() 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.imshow('test', np.zeros((1, 1, 3)))
cv2.waitKey(1) cv2.waitKey(1)
cv2.destroyAllWindows() cv2.destroyAllWindows()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论