`PIL.ImageDraw.text(anchor=...)` removal, reduce to `>=7.1.2` (#4842)
Browse files* Unpin Pillow
* Update requirements.txt
* Update plots.py
- requirements.txt +1 -1
- utils/plots.py +4 -3
requirements.txt
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
matplotlib>=3.2.2
|
5 |
numpy>=1.18.5
|
6 |
opencv-python>=4.1.2
|
7 |
-
Pillow>=
|
8 |
PyYAML>=5.3.1
|
9 |
scipy>=1.4.1
|
10 |
torch>=1.7.0
|
|
|
4 |
matplotlib>=3.2.2
|
5 |
numpy>=1.18.5
|
6 |
opencv-python>=4.1.2
|
7 |
+
Pillow>=7.1.2
|
8 |
PyYAML>=5.3.1
|
9 |
scipy>=1.4.1
|
10 |
torch>=1.7.0
|
utils/plots.py
CHANGED
@@ -3,11 +3,11 @@
|
|
3 |
Plotting utils
|
4 |
"""
|
5 |
|
6 |
-
import math
|
7 |
from copy import copy
|
8 |
from pathlib import Path
|
9 |
|
10 |
import cv2
|
|
|
11 |
import matplotlib
|
12 |
import matplotlib.pyplot as plt
|
13 |
import numpy as np
|
@@ -80,9 +80,10 @@ class Annotator:
|
|
80 |
if self.pil or not is_ascii(label):
|
81 |
self.draw.rectangle(box, width=self.lw, outline=color) # box
|
82 |
if label:
|
83 |
-
w = self.font.getsize(label)
|
84 |
self.draw.rectangle([box[0], box[1] - self.fh, box[0] + w + 1, box[1] + 1], fill=color)
|
85 |
-
self.draw.text((box[0], box[1]), label, fill=txt_color, font=self.font, anchor='ls')
|
|
|
86 |
else: # cv2
|
87 |
c1, c2 = (int(box[0]), int(box[1])), (int(box[2]), int(box[3]))
|
88 |
cv2.rectangle(self.im, c1, c2, color, thickness=self.lw, lineType=cv2.LINE_AA)
|
|
|
3 |
Plotting utils
|
4 |
"""
|
5 |
|
|
|
6 |
from copy import copy
|
7 |
from pathlib import Path
|
8 |
|
9 |
import cv2
|
10 |
+
import math
|
11 |
import matplotlib
|
12 |
import matplotlib.pyplot as plt
|
13 |
import numpy as np
|
|
|
80 |
if self.pil or not is_ascii(label):
|
81 |
self.draw.rectangle(box, width=self.lw, outline=color) # box
|
82 |
if label:
|
83 |
+
w, h = self.font.getsize(label) # text width
|
84 |
self.draw.rectangle([box[0], box[1] - self.fh, box[0] + w + 1, box[1] + 1], fill=color)
|
85 |
+
# self.draw.text((box[0], box[1]), label, fill=txt_color, font=self.font, anchor='ls') # for PIL>8.0
|
86 |
+
self.draw.text((box[0], box[1] - h), label, fill=txt_color, font=self.font)
|
87 |
else: # cv2
|
88 |
c1, c2 = (int(box[0]), int(box[1])), (int(box[2]), int(box[3]))
|
89 |
cv2.rectangle(self.im, c1, c2, color, thickness=self.lw, lineType=cv2.LINE_AA)
|