Fix 2 for Arial.ttf redownloads with hub inference (#4628)
This commit is contained in:
1 parent
ba0f80874f
commit
a4e8f78c5e
2 files changed
+27
-22
No files matched your search
+19
-19
@@ -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))
|
||||
Reference in new issue
Block a user