Browse Source

Fix `check_suffix()` (#4712)

Fix a bug when `file=''`
modifyDataloader
Glenn Jocher GitHub 3 years ago
parent
commit
f984cce52a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      utils/general.py

+ 2
- 2
utils/general.py View File



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]:


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

Loading…
Cancel
Save