Skip to content

Commit

Permalink
Merge pull request #4 from ultralytics/master
Browse files Browse the repository at this point in the history
Windows Python 3.7 .isfile() fix (ultralytics#9879)
  • Loading branch information
NagatoYuki0943 committed Oct 25, 2022
2 parents fbbb55a + fba61e5 commit f63c86a
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 f63c86a

Please sign in to comment.