forked from ultralytics/yolov5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 2 for Arial.ttf redownloads with hub inference (ultralytics#4628)
- Loading branch information
1 parent
e9f4767
commit da0be6c
Showing
2 changed files
with
27 additions
and
22 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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import sys | ||
from pathlib import Path | ||
|
||
import torch | ||
from PIL import ImageFont | ||
|
||
FILE = Path(__file__).absolute() | ||
ROOT = FILE.parents[1] # yolov5/ dir | ||
if str(ROOT) not in sys.path: | ||
sys.path.append(str(ROOT)) # add ROOT to PATH | ||
|
||
# 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)) | ||
# import sys | ||
# from pathlib import Path | ||
# | ||
# import torch | ||
# from PIL import ImageFont | ||
# | ||
# FILE = Path(__file__).absolute() | ||
# ROOT = FILE.parents[1] # yolov5/ dir | ||
# if str(ROOT) not in sys.path: | ||
# sys.path.append(str(ROOT)) # add ROOT to PATH | ||
# | ||
# # 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