Ultralytics Asset URL Update (#14345)

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-10 21:12:33 +02:00 committed by GitHub
parent 470b120a1b
commit 2d332a1cb1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 55 additions and 53 deletions

View file

@ -195,7 +195,7 @@ class RF100Benchmark:
(shutil.rmtree("rf-100"), os.mkdir("rf-100")) if os.path.exists("rf-100") else os.mkdir("rf-100")
os.chdir("rf-100")
os.mkdir("ultralytics-benchmarks")
safe_download("https://github.com/ultralytics/yolov5/releases/download/v1.0/datasets_links.txt")
safe_download("https://github.com/ultralytics/assets/releases/download/v0.0.0/datasets_links.txt")
with open(ds_link_txt, "r") as file:
for line in file:

View file

@ -315,7 +315,7 @@ def check_font(font="Arial.ttf"):
return matches[0]
# Download to USER_CONFIG_DIR if missing
url = f"https://github.com/ultralytics/yolov5/releases/download/v1.0/{name}"
url = f"https://github.com/ultralytics/assets/releases/download/v0.0.0/{name}"
if downloads.is_url(url, check=True):
downloads.safe_download(url=url, file=file)
return file

View file

@ -194,14 +194,12 @@ def unzip_file(file, path=None, exclude=(".DS_Store", "__MACOSX"), exist_ok=Fals
return path # return unzip dir
def check_disk_space(
url="https://github.com/ultralytics/yolov5/releases/download/v1.0/coco8.zip", path=Path.cwd(), sf=1.5, hard=True
):
def check_disk_space(url="https://ultralytics.com/assets/coco8.zip", path=Path.cwd(), sf=1.5, hard=True):
"""
Check if there is sufficient disk space to download and store a file.
Args:
url (str, optional): The URL to the file. Defaults to 'https://ultralytics.com/assets/coco8.zip'.
url (str, optional): The URL to the file. Defaults to 'https://github.com/ultralytics/assets/releases/download/v0.0.0/coco8.zip'.
path (str | Path, optional): The path or drive to check the available free space on.
sf (float, optional): Safety factor, the multiplier for the required free space. Defaults to 2.0.
hard (bool, optional): Whether to throw an error or not on insufficient disk space. Defaults to True.
@ -322,7 +320,11 @@ def safe_download(
if "://" not in str(url) and Path(url).is_file(): # URL exists ('://' check required in Windows Python<3.10)
f = Path(url) # filename
elif not f.is_file(): # URL and file do not exist
desc = f"Downloading {url if gdrive else clean_url(url)} to '{f}'"
uri = (url if gdrive else clean_url(url)).replace( # cleaned and aliased url
"https://github.com/ultralytics/assets/releases/download/v0.0.0/",
"https://ultralytics.com/assets/", # assets alias
)
desc = f"Downloading {uri} to '{f}'"
LOGGER.info(f"{desc}...")
f.parent.mkdir(parents=True, exist_ok=True) # make directory if missing
check_disk_space(url, path=f.parent)
@ -356,10 +358,10 @@ def safe_download(
f.unlink() # remove partial downloads
except Exception as e:
if i == 0 and not is_online():
raise ConnectionError(emojis(f"❌ Download failure for {url}. Environment is not online.")) from e
raise ConnectionError(emojis(f"❌ Download failure for {uri}. Environment is not online.")) from e
elif i >= retry:
raise ConnectionError(emojis(f"❌ Download failure for {url}. Retry limit reached.")) from e
LOGGER.warning(f"⚠️ Download failure, retrying {i + 1}/{retry} {url}...")
raise ConnectionError(emojis(f"❌ Download failure for {uri}. Retry limit reached.")) from e
LOGGER.warning(f"⚠️ Download failure, retrying {i + 1}/{retry} {uri}...")
if unzip and f.exists() and f.suffix in {"", ".zip", ".tar", ".gz"}:
from zipfile import is_zipfile