From dce1fefc57b803f7d3dba84951d08cf244dec71c Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 20 Sep 2021 13:43:38 +0200 Subject: [PATCH 1/2] Annotator `check_font()` RANK -1 remove progress --- utils/plots.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/utils/plots.py b/utils/plots.py index 5ff72cb144e2..c7bba2c2d9aa 100644 --- a/utils/plots.py +++ b/utils/plots.py @@ -3,11 +3,12 @@ Plotting utils """ +import math +import os from copy import copy from pathlib import Path import cv2 -import math import matplotlib import matplotlib.pyplot as plt import numpy as np @@ -21,6 +22,7 @@ # Settings CONFIG_DIR = user_config_dir() # Ultralytics settings dir +RANK = int(os.getenv('RANK', -1)) matplotlib.rc('font', **{'size': 11}) matplotlib.use('Agg') # for writing to files only @@ -55,12 +57,13 @@ def check_font(font='Arial.ttf', size=10): except Exception as e: # download if missing url = "https://ultralytics.com/assets/" + font.name print(f'Downloading {url} to {font}...') - torch.hub.download_url_to_file(url, str(font)) + torch.hub.download_url_to_file(url, str(font), progress=False) return ImageFont.truetype(str(font), size) class Annotator: - check_font() # download TTF if necessary + if RANK in (0, -1): + check_font() # download TTF if necessary # YOLOv5 Annotator for train/val mosaics and jpgs and detect/hub inference annotations def __init__(self, im, line_width=None, font_size=None, font='Arial.ttf', pil=True): From a5a163967b50969dfe7a6c68beb7e4b68a6353ad Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 20 Sep 2021 13:46:09 +0200 Subject: [PATCH 2/2] Cleanup --- utils/plots.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/plots.py b/utils/plots.py index c7bba2c2d9aa..1e6ee516387a 100644 --- a/utils/plots.py +++ b/utils/plots.py @@ -62,7 +62,7 @@ def check_font(font='Arial.ttf', size=10): class Annotator: - if RANK in (0, -1): + if RANK in (-1, 0): check_font() # download TTF if necessary # YOLOv5 Annotator for train/val mosaics and jpgs and detect/hub inference annotations