-
-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-download Arial.ttf on init (#4606)
* Auto-download Arial.ttf on init * Fix ROOT
- Loading branch information
1 parent
bb4da08
commit e7d1842
Showing
2 changed files
with
20 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters