PIL.ImageDraw.text(anchor=...) removal, reduce to >=7.1.2 (#4842)

* Unpin Pillow

* Update requirements.txt

* Update plots.py
This commit is contained in:
Glenn Jocher authored and GitHub committed 2021-09-17 13:02:37 +02:00
1 parent e83792e65c
commit 3a822a22ce
2 files changed
+5 -4

No files matched your search

+4 -3
View File
@@ -3,11 +3,11 @@
Plotting utils
"""
import math
from copy import copy
from pathlib import Path
import cv2
import math
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
@@ -80,9 +80,10 @@ class Annotator:
if self.pil or not is_ascii(label):
self.draw.rectangle(box, width=self.lw, outline=color) # box
if label:
w = self.font.getsize(label)[0] # text width
w, h = self.font.getsize(label) # text width
self.draw.rectangle([box[0], box[1] - self.fh, box[0] + w + 1, box[1] + 1], fill=color)
self.draw.text((box[0], box[1]), label, fill=txt_color, font=self.font, anchor='ls')
# self.draw.text((box[0], box[1]), label, fill=txt_color, font=self.font, anchor='ls') # for PIL>8.0
self.draw.text((box[0], box[1] - h), label, fill=txt_color, font=self.font)
else: # cv2
c1, c2 = (int(box[0]), int(box[1])), (int(box[2]), int(box[3]))
cv2.rectangle(self.im, c1, c2, color, thickness=self.lw, lineType=cv2.LINE_AA)