Add is_colab() and is_kaggle() (#41)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Glenn Jocher 2022-11-08 17:14:49 +01:00 committed by GitHub
parent f56c9bcc26
commit 4c68b9dcf6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 103 additions and 119 deletions

View file

@ -6,7 +6,7 @@ import numpy as np
import torch
from PIL import Image, ImageDraw, ImageFont
from ultralytics.yolo.utils import CONFIG_DIR, FONT
from ultralytics.yolo.utils import FONT, USER_CONFIG_DIR
from .checks import check_font, check_requirements, is_ascii
from .files import increment_path
@ -150,7 +150,7 @@ class Annotator:
def check_pil_font(font=FONT, size=10):
# Return a PIL TrueType Font, downloading to CONFIG_DIR if necessary
font = Path(font)
font = font if font.exists() else (CONFIG_DIR / font.name)
font = font if font.exists() else (USER_CONFIG_DIR / font.name)
try:
return ImageFont.truetype(str(font) if font.exists() else font.name, size)
except Exception: # download if missing