diff --git a/utils/plots.py b/utils/plots.py index fa49dc19d..f5c53cae5 100644 --- a/utils/plots.py +++ b/utils/plots.py @@ -83,7 +83,8 @@ def box_label(self, box, label='', color=(128, 128, 128), txt_color=(255, 255, 2 if self.pil or not is_ascii(label): self.draw.rectangle(box, width=self.lw, outline=color) # box if label: - w, h = self.font.getsize(label) # text width, height + bbox = self.font.getbbox(label) + w, h = bbox[2] - bbox[0], bbox[3] - bbox[1] # text width, height outside = box[1] - h >= 0 # label fits outside box self.draw.rectangle( (box[0], box[1] - h if outside else box[1], box[0] + w + 1,