Skip to content

Commit

Permalink
Windows Python 3.7 .isfile() fix (#9879)
Browse files Browse the repository at this point in the history
* Update dataloaders.py

Signed-off-by: SSTato <1210546396@qq.com>

* Update general.py

Signed-off-by: SSTato <1210546396@qq.com>

* Update general.py

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update dataloaders.py

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update dataloaders.py

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update general.py

Signed-off-by: SSTato <1210546396@qq.com>

* Update ci-testing.yml

Signed-off-by: SSTato <1210546396@qq.com>

* Update ci-testing.yml

Signed-off-by: SSTato <1210546396@qq.com>

* Update ci-testing.yml

Signed-off-by: SSTato <1210546396@qq.com>

* Update general.py

Signed-off-by: SSTato <1210546396@qq.com>

* Update general.py

Signed-off-by: SSTato <1210546396@qq.com>

* Update dataloaders.py

Signed-off-by: SSTato <1210546396@qq.com>

Signed-off-by: SSTato <1210546396@qq.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
  • Loading branch information
SSTato and glenn-jocher committed Oct 24, 2022
1 parent eef9057 commit fba61e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion utils/dataloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def __init__(self, sources='streams.txt', img_size=640, stride=32, auto=True, tr
self.img_size = img_size
self.stride = stride
self.vid_stride = vid_stride # video frame-rate stride
sources = Path(sources).read_text().rsplit() if Path(sources).is_file() else [sources]
sources = Path(sources).read_text().rsplit() if os.path.isfile(sources) else [sources]
n = len(sources)
self.sources = [clean_str(x) for x in sources] # clean source names for later
self.imgs, self.fps, self.frames, self.threads = [None] * n, [0] * n, [0] * n, [None] * n
Expand Down
6 changes: 3 additions & 3 deletions utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,12 @@ def check_file(file, suffix=''):
# Search/download file (if necessary) and return path
check_suffix(file, suffix) # optional
file = str(file) # convert to str()
if Path(file).is_file() or not file: # exists
if os.path.isfile(file) or not file: # exists
return file
elif file.startswith(('http:/', 'https:/')): # download
url = file # warning: Pathlib turns :// -> :/
file = Path(urllib.parse.unquote(file).split('?')[0]).name # '%2F' to '/', split https://url.com/file.txt?auth
if Path(file).is_file():
if os.path.isfile(file):
LOGGER.info(f'Found {url} locally at {file}') # file already exists
else:
LOGGER.info(f'Downloading {url} to {file}...')
Expand Down Expand Up @@ -586,7 +586,7 @@ def download(url, dir='.', unzip=True, delete=True, curl=False, threads=1, retry
def download_one(url, dir):
# Download 1 file
success = True
if Path(url).is_file():
if os.path.isfile(url):
f = Path(url) # filename
else: # does not exist
f = dir / Path(url).name
Expand Down

0 comments on commit fba61e5

Please sign in to comment.