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

Fix `check_suffix()` (#4712)

Fix a bug when `file=''`
上级 a2b3c716
...@@ -244,7 +244,7 @@ def check_imshow(): ...@@ -244,7 +244,7 @@ def check_imshow():
def check_suffix(file='yolov5s.pt', suffix=('.pt',), msg=''): def check_suffix(file='yolov5s.pt', suffix=('.pt',), msg=''):
# Check file(s) for acceptable suffixes # Check file(s) for acceptable suffixes
if any(suffix): if file and suffix:
if isinstance(suffix, str): if isinstance(suffix, str):
suffix = [suffix] suffix = [suffix]
for f in file if isinstance(file, (list, tuple)) else [file]: for f in file if isinstance(file, (list, tuple)) else [file]:
...@@ -258,7 +258,7 @@ def check_yaml(file, suffix=('.yaml', '.yml')): ...@@ -258,7 +258,7 @@ def check_yaml(file, suffix=('.yaml', '.yml')):
def check_file(file, suffix=''): def check_file(file, suffix=''):
# Search/download file (if necessary) and return path # Search/download file (if necessary) and return path
check_suffix(file, suffix) check_suffix(file, suffix) # optional
file = str(file) # convert to str() file = str(file) # convert to str()
if Path(file).is_file() or file == '': # exists if Path(file).is_file() or file == '': # exists
return file return file
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论