Unverified 提交 a4c66187 authored 作者: Zengyf-CVer's avatar Zengyf-CVer 提交者: GitHub

Fix `detect.py --view-img` for non-ASCII paths (#7093)

* Update detect.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update general.py * Update detect.py * Update general.py * Update general.py * Update general.py * Update general.py * Update general.py * Update general.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update general.py * Update general.py Co-authored-by: 's avatarpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com>
上级 d115bbf5
...@@ -905,6 +905,9 @@ def increment_path(path, exist_ok=False, sep='', mkdir=False): ...@@ -905,6 +905,9 @@ def increment_path(path, exist_ok=False, sep='', mkdir=False):
# OpenCV Chinese-friendly functions ------------------------------------------------------------------------------------ # OpenCV Chinese-friendly functions ------------------------------------------------------------------------------------
imshow_ = cv2.imshow # copy to avoid recursion errors
def imread(path): def imread(path):
return cv2.imdecode(np.fromfile(path, np.uint8), cv2.IMREAD_COLOR) return cv2.imdecode(np.fromfile(path, np.uint8), cv2.IMREAD_COLOR)
...@@ -917,7 +920,11 @@ def imwrite(path, im): ...@@ -917,7 +920,11 @@ def imwrite(path, im):
return False return False
cv2.imread, cv2.imwrite = imread, imwrite # redefine def imshow(path, im):
imshow_(path.encode('unicode_escape').decode(), im)
cv2.imread, cv2.imwrite, cv2.imshow = imread, imwrite, imshow # redefine
# Variables ------------------------------------------------------------------------------------------------------------ # Variables ------------------------------------------------------------------------------------------------------------
NCOLS = 0 if is_docker() else shutil.get_terminal_size().columns # terminal window size for tqdm NCOLS = 0 if is_docker() else shutil.get_terminal_size().columns # terminal window size for tqdm
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论