DDP, Comet, URLError fixes, improved error handling (#658)

Co-authored-by: Ayush Chaurasia <ayush.chaurarsia@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tungway1990 <68179274+Tungway1990@users.noreply.github.com>
This commit is contained in:
Glenn Jocher 2023-01-28 01:31:41 +01:00 committed by GitHub
parent 6c44ce21d9
commit a5410ed79e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 79 additions and 81 deletions

View file

@ -18,8 +18,8 @@ import psutil
import torch
from IPython import display
from ultralytics.yolo.utils import (AUTOINSTALL, FONT, LOGGER, ROOT, USER_CONFIG_DIR, TryExcept, colorstr, emojis,
is_colab, is_docker, is_jupyter)
from ultralytics.yolo.utils import (AUTOINSTALL, FONT, LOGGER, ROOT, USER_CONFIG_DIR, TryExcept, colorstr, downloads,
emojis, is_colab, is_docker, is_jupyter)
def is_ascii(s) -> bool:
@ -123,9 +123,7 @@ def check_font(font: str = FONT, progress: bool = False) -> None:
# Check if font file exists at the source or destination path
if not font.exists() and not file.exists():
# Download font file
url = f'https://ultralytics.com/assets/{font.name}'
LOGGER.info(f'Downloading {url} to {file}...')
torch.hub.download_url_to_file(url, str(file), progress=progress)
downloads.safe_download(file=file, url=f'https://ultralytics.com/assets/{font.name}', progress=progress)
def check_online() -> bool:
@ -215,9 +213,7 @@ def check_file(file, suffix=''):
if Path(file).is_file():
LOGGER.info(f'Found {url} locally at {file}') # file already exists
else:
LOGGER.info(f'Downloading {url} to {file}...')
torch.hub.download_url_to_file(url, file)
assert Path(file).exists() and Path(file).stat().st_size > 0, f'File download failed: {url}' # check
downloads.safe_download(file=file, url=url)
return file
else: # search
files = []