ultralytics 8.0.204 Segment ONNX Runtime example (#6088)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: Kapil Raj <103250862+raj-kapil@users.noreply.github.com>
Co-authored-by: jamjamjon <51357717+jamjamjon@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: snyk-bot <snyk-bot@snyk.io>
This commit is contained in:
Glenn Jocher 2023-11-02 21:17:00 +01:00 committed by GitHub
parent 465df3024f
commit ff0aba10c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 563 additions and 37 deletions

View file

@ -262,6 +262,14 @@ def safe_download(url,
min_bytes (float, optional): The minimum number of bytes that the downloaded file should have, to be considered
a successful download. Default: 1E0.
progress (bool, optional): Whether to display a progress bar during the download. Default: True.
Example:
```python
from ultralytics.utils.downloads import safe_download
link = "https://ultralytics.com/assets/bus.jpg"
path = safe_download(link)
```
"""
# Check if the URL is a Google Drive link
@ -269,11 +277,8 @@ def safe_download(url,
if gdrive:
url, file = get_google_drive_file_info(url)
f = dir / (file if gdrive else url2file(url)) if dir else Path(file) # URL converted to filename
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
assert dir or file, 'dir or file required for download'
f = Path(dir or '.') / (file or url2file(url)) # URL converted to filename
if not f.is_file(): # URL and file do not exist
desc = f"Downloading {url if gdrive else clean_url(url)} to '{f}'"
LOGGER.info(f'{desc}...')
f.parent.mkdir(parents=True, exist_ok=True) # make directory if missing