ultralytics 8.2.66 HUB model autodownload (#14702)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Glenn Jocher 2024-07-26 00:31:41 +02:00 committed by GitHub
parent 1d5d105c62
commit 9130399974
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 14 additions and 11 deletions

View file

@ -484,7 +484,7 @@ def check_model_file_from_stem(model="yolov8n"):
return model
def check_file(file, suffix="", download=True, hard=True):
def check_file(file, suffix="", download=True, download_dir=".", hard=True):
"""Search/download file (if necessary) and return path."""
check_suffix(file, suffix) # optional
file = str(file).strip() # convert to string and strip spaces
@ -497,12 +497,12 @@ def check_file(file, suffix="", download=True, hard=True):
return file
elif download and file.lower().startswith(("https://", "http://", "rtsp://", "rtmp://", "tcp://")): # download
url = file # warning: Pathlib turns :// -> :/
file = url2file(file) # '%2F' to '/', split https://url.com/file.txt?auth
if Path(file).exists():
file = Path(download_dir) / url2file(file) # '%2F' to '/', split https://url.com/file.txt?auth
if file.exists():
LOGGER.info(f"Found {clean_url(url)} locally at {file}") # file already exists
else:
downloads.safe_download(url=url, file=file, unzip=False)
return file
return str(file)
else: # search
files = glob.glob(str(ROOT / "**" / file), recursive=True) or glob.glob(str(ROOT.parent / file)) # find file
if not files and hard: