Browse Source

Ability to dowlnoad older assets (#7767)

* Ability to dowlnoad older assets

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Cleanup

* Cleanup2

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
modifyDataloader
Cristi Fati GitHub 2 years ago
parent
commit
4870064629
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      utils/downloads.py

+ 5
- 3
utils/downloads.py View File

@@ -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

Loading…
Cancel
Save