|
|
@@ -43,8 +43,8 @@ def safe_download(file, url, url2=None, min_bytes=1E0, error_msg=''): |
|
|
|
LOGGER.info('') |
|
|
|
|
|
|
|
|
|
|
|
def attempt_download(file, repo='ultralytics/yolov5'): # from utils.downloads import *; attempt_download() |
|
|
|
# Attempt file download if does not exist |
|
|
|
def attempt_download(file, repo='ultralytics/yolov5', release='latest'): |
|
|
|
# Attempt file download from GitHub release assets if not found locally |
|
|
|
from utils.general import LOGGER |
|
|
|
|
|
|
|
file = Path(str(file).strip().replace("'", '')) |
|
|
@@ -62,8 +62,10 @@ def attempt_download(file, repo='ultralytics/yolov5'): # from utils.downloads i |
|
|
|
|
|
|
|
# GitHub assets |
|
|
|
file.parent.mkdir(parents=True, exist_ok=True) # make parent dir (if required) |
|
|
|
if release != 'latest' and not release.startswith('tags/'): |
|
|
|
release = f'tags/{release}' # prepend i.e. tags/v6.1 |
|
|
|
try: |
|
|
|
response = requests.get(f'https://api.github.com/repos/{repo}/releases/latest').json() # github api |
|
|
|
response = requests.get(f'https://api.github.com/repos/{repo}/releases/{release}').json() # github api |
|
|
|
assets = [x['name'] for x in response['assets']] # release assets, i.e. ['yolov5s.pt', 'yolov5m.pt', ...] |
|
|
|
tag = response['tag_name'] # i.e. 'v1.0' |
|
|
|
except Exception: # fallback plan |