Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PIL show() and save() #8202

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 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)

Check warning on line 335 in ultralytics/utils/plotting.py

View check run for this annotation

Codecov / codecov/patch

ultralytics/utils/plotting.py#L335

Added line #L335 was not covered by tests

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))

Check warning on line 339 in ultralytics/utils/plotting.py

View check run for this annotation

Codecov / codecov/patch

ultralytics/utils/plotting.py#L339

Added line #L339 was not covered by tests

def draw_region(self, reg_pts=None, color=(0, 255, 0), thickness=5):
"""
Expand Down Expand Up @@ -422,8 +422,6 @@
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