diff --git a/utils/plots.py b/utils/plots.py index fa49dc19d..6c8f812d2 100644 --- a/utils/plots.py +++ b/utils/plots.py @@ -83,7 +83,7 @@ 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 + w, h = self.font.getbbox(label)[2:] # 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,