Fix PIL show() and save() (#8202)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Glenn Jocher 2024-02-14 14:34:44 +01:00 committed by GitHub
parent 850ca8587f
commit 5e81651b4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -332,11 +332,11 @@ class Annotator:
def show(self, title=None):
"""Show the annotated image."""
(self.im if isinstance(self.im, Image.Image) else Image.fromarray(self.im[..., ::-1])).show(title)
Image.fromarray(np.asarray(self.im)[..., ::-1]).show(title)
def save(self, filename="image.jpg"):
"""Save the annotated image to 'filename'."""
(self.im if isinstance(self.im, Image.Image) else Image.fromarray(self.im[..., ::-1])).save(filename)
cv2.imwrite(filename, np.asarray(self.im))
def draw_region(self, reg_pts=None, color=(0, 255, 0), thickness=5):
"""
@ -422,8 +422,6 @@ class Annotator:
shape (tuple): imgsz for model inference
radius (int): Keypoint radius value
"""
nkpts, ndim = keypoints.shape
nkpts == 17 and ndim == 3
for i, k in enumerate(keypoints):
if i in indices:
x_coord, y_coord = k[0], k[1]