|
|
@ -19,9 +19,9 @@ import requests
|
|
|
|
import torch
|
|
|
|
import torch
|
|
|
|
from matplotlib import font_manager
|
|
|
|
from matplotlib import font_manager
|
|
|
|
|
|
|
|
|
|
|
|
from ultralytics.yolo.utils import (AUTOINSTALL, LOGGER, ONLINE, RANK, ROOT, USER_CONFIG_DIR, TryExcept, clean_url,
|
|
|
|
from ultralytics.yolo.utils import (AUTOINSTALL, LOGGER, ONLINE, ROOT, USER_CONFIG_DIR, TryExcept, clean_url, colorstr,
|
|
|
|
colorstr, downloads, emojis, is_colab, is_docker, is_kaggle, is_online,
|
|
|
|
downloads, emojis, is_colab, is_docker, is_kaggle, is_online, is_pip_package,
|
|
|
|
is_pip_package, url2file)
|
|
|
|
url2file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_ascii(s) -> bool:
|
|
|
|
def is_ascii(s) -> bool:
|
|
|
@ -164,26 +164,23 @@ def check_font(font='Arial.ttf'):
|
|
|
|
Returns:
|
|
|
|
Returns:
|
|
|
|
file (Path): Resolved font file path.
|
|
|
|
file (Path): Resolved font file path.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
from ultralytics.yolo.utils.torch_utils import torch_distributed_zero_first
|
|
|
|
name = Path(font).name
|
|
|
|
|
|
|
|
|
|
|
|
with torch_distributed_zero_first(RANK):
|
|
|
|
# Check USER_CONFIG_DIR
|
|
|
|
name = Path(font).name
|
|
|
|
file = USER_CONFIG_DIR / name
|
|
|
|
|
|
|
|
if file.exists():
|
|
|
|
# Check USER_CONFIG_DIR
|
|
|
|
return file
|
|
|
|
file = USER_CONFIG_DIR / name
|
|
|
|
|
|
|
|
if file.exists():
|
|
|
|
# Check system fonts
|
|
|
|
return file
|
|
|
|
matches = [s for s in font_manager.findSystemFonts() if font in s]
|
|
|
|
|
|
|
|
if any(matches):
|
|
|
|
# Check system fonts
|
|
|
|
return matches[0]
|
|
|
|
matches = [s for s in font_manager.findSystemFonts() if font in s]
|
|
|
|
|
|
|
|
if any(matches):
|
|
|
|
# Download to USER_CONFIG_DIR if missing
|
|
|
|
return matches[0]
|
|
|
|
url = f'https://ultralytics.com/assets/{name}'
|
|
|
|
|
|
|
|
if downloads.is_url(url):
|
|
|
|
# Download to USER_CONFIG_DIR if missing
|
|
|
|
downloads.safe_download(url=url, file=file)
|
|
|
|
url = f'https://ultralytics.com/assets/{name}'
|
|
|
|
return file
|
|
|
|
if downloads.is_url(url):
|
|
|
|
|
|
|
|
downloads.safe_download(url=url, file=file)
|
|
|
|
|
|
|
|
return file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_python(minimum: str = '3.7.0') -> bool:
|
|
|
|
def check_python(minimum: str = '3.7.0') -> bool:
|
|
|
|