Skip to content

Commit

Permalink
Fix PIL show() and save() (#8202)
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
  • Loading branch information
glenn-jocher committed Feb 14, 2024
1 parent 850ca85 commit 5e81651
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions ultralytics/utils/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ def result(self):

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):
"""
Expand Down Expand Up @@ -422,8 +422,6 @@ def draw_specific_points(self, keypoints, indices=[2, 5, 7], shape=(640, 640), r
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]
Expand Down

0 comments on commit 5e81651

Please sign in to comment.