Improve plots.py robustness (#5616)
* Improve plots.py robustness Addresses issues #5374, #5395, #5611 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
69032519bc
commit
def7a0fd19
|
|
@ -17,7 +17,8 @@ import seaborn as sn
|
||||||
import torch
|
import torch
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
|
||||||
from utils.general import clip_coords, increment_path, is_ascii, is_chinese, user_config_dir, xywh2xyxy, xyxy2xywh
|
from utils.general import (Timeout, check_requirements, clip_coords, increment_path, is_ascii, is_chinese, try_except,
|
||||||
|
user_config_dir, xywh2xyxy, xyxy2xywh)
|
||||||
from utils.metrics import fitness
|
from utils.metrics import fitness
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
|
|
@ -58,7 +59,10 @@ def check_font(font='Arial.ttf', size=10):
|
||||||
url = "https://ultralytics.com/assets/" + font.name
|
url = "https://ultralytics.com/assets/" + font.name
|
||||||
print(f'Downloading {url} to {font}...')
|
print(f'Downloading {url} to {font}...')
|
||||||
torch.hub.download_url_to_file(url, str(font), progress=False)
|
torch.hub.download_url_to_file(url, str(font), progress=False)
|
||||||
return ImageFont.truetype(str(font), size)
|
try:
|
||||||
|
return ImageFont.truetype(str(font), size)
|
||||||
|
except TypeError:
|
||||||
|
check_requirements('Pillow>=8.4.0') # known issue https://github.com/ultralytics/yolov5/issues/5374
|
||||||
|
|
||||||
|
|
||||||
class Annotator:
|
class Annotator:
|
||||||
|
|
@ -320,6 +324,8 @@ def plot_val_study(file='', dir='', x=None): # from utils.plots import *; plot_
|
||||||
plt.savefig(f, dpi=300)
|
plt.savefig(f, dpi=300)
|
||||||
|
|
||||||
|
|
||||||
|
@try_except # known issue https://github.com/ultralytics/yolov5/issues/5395
|
||||||
|
@Timeout(30) # known issue https://github.com/ultralytics/yolov5/issues/5611
|
||||||
def plot_labels(labels, names=(), save_dir=Path('')):
|
def plot_labels(labels, names=(), save_dir=Path('')):
|
||||||
# plot dataset labels
|
# plot dataset labels
|
||||||
print('Plotting labels... ')
|
print('Plotting labels... ')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue