Auto-download Arial.ttf on init (#4606)

* Auto-download Arial.ttf on init

* Fix ROOT
This commit is contained in:
Glenn Jocher authored and GitHub committed 2021-08-30 14:58:22 +02:00
1 parent bb4da083d1
commit e7d1842a98
2 files changed
+20 -5

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
from pathlib import Path
import torch
from PIL import ImageFont
FILE = Path(__file__).absolute()
ROOT = FILE.parents[1] # yolov5/ dir
# Check YOLOv5 Annotator font
font = 'Arial.ttf'
try:
ImageFont.truetype(font)
except Exception as e: # download if missing
url = "https://ultralytics.com/assets/" + font
print(f'Downloading {url} to {ROOT / font}...')
torch.hub.download_url_to_file(url, str(ROOT / font))