-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
What did you do?
I am using the below code (with show_image=True) to show an image. Works with Pillow==8.4.0 but fails with Pillow==9.0.0. The image viewer applications opens up but the temporary file that Pillow produces is not there.
def show_detections(output_path, show_image, image, scored_boxes_by_class_index, class_index_to_name):
# Draw all results
ctx = ImageDraw.Draw(image, mode = "RGBA")
color_idx = 0
for class_index, scored_boxes in scored_boxes_by_class_index.items():
for i in range(scored_boxes.shape[0]):
scored_box = scored_boxes[i,:]
class_name = class_index_to_name[class_index]
text = "%s %1.2f" % (class_name, scored_box[4])
color = _class_to_color(class_index = class_index)
_draw_rectangle(ctx = ctx, corners = scored_box[0:4], color = color, thickness = 2)
_draw_text(image = image, text = text, position = (scored_box[1], scored_box[0]), color = color, scale = 1.5, offset_lines = -1)
# Output
if show_image:
image.show()
if output_path is not None:
image.save(output_path)
print("Wrote detection results to '%s'" % output_path)
Inserting a sleep thereafter doesn't help.
What did you expect to happen?
The temporary file should be present and the application should be able to view it.
What actually happened?
Image file not found.
What are your OS, Python and Pillow versions?
- OS: Ubuntu
- Python: 3.8.5
- Pillow: 9.0.0
code goes here