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:
parent
1d5d105c62
commit
9130399974
5 changed files with 14 additions and 11 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue