receyuki / stable-diffusion-prompt-reader

A simple standalone viewer for reading prompts from Stable Diffusion generated image outside the webui.
MIT License
1.08k stars 69 forks source link

[BUG]: Big images can't be handled #12

Closed Woisek closed 1 year ago

Woisek commented 1 year ago

When trying to open a 3840x1200 pixel size PNG, I get the following:

Traceback (most recent call last): File "main.py", line 4, in File "app.py", line 687, in main File "app.py", line 348, in init File "app.py", line 390, in display_info File "app.py", line 448, in resize_image File "customtkinter\windows\widgets\ctk_label.py", line 207, in configure self._update_image() File "customtkinter\windows\widgets\ctk_label.py", line 132, in _update_image self._label.configure(image=self._image.create_scaled_photo_image(self._get_widget_scaling(), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "customtkinter\windows\widgets\image\ctk_image.py", line 113, in create_scaled_photo_image return self._get_scaled_light_photo_image(scaled_size) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "customtkinter\windows\widgets\image\ctk_image.py", line 99, in _get_scaled_light_photo_image self._scaled_light_photo_images[scaled_size] = ImageTk.PhotoImage(self._light_image.resize(scaled_size)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "PIL\Image.py", line 2193, in resize ValueError: height and width must be > 0

Is there a solution? 🤔

receyuki commented 1 year ago

Wow! What gpu are you using? How can you generate such a large image size! I can't reproduce the problem at the moment, and it seems to be a problem with the library I'm using. Have you tried the executable version in the release? Does the executable have the same problem?

Woisek commented 1 year ago

Wow! What gpu are you using?

Just a 2070 SUPER with 8GB VRAM ...

How can you generate such a large image size!

Upscaling ... 😁 This is my dual wallpaper resolution. I love to generate wallpapers. 😋 I also do full DIN A4 size and can go up to 3240x4608. 😎 Maybe you should know, that people are already generating 16k images ... 😱 So be prepared with you cool program. 😉

Have you tried the executable version in the release? Does the executable have the same problem?

I only have the exe. And it doesn't matter if I use "Open with" or start the exe and pull the image into it. I hope you can fix this. 👍

receyuki commented 1 year ago

Upscaling ... 😁 This is my dual wallpaper resolution. I love to generate wallpapers. 😋 I also do full DIN A4 size and can go up to 3240x4608. 😎 Maybe you should know, that people are already generating 16k images ... 😱 So be prepared with you cool program. 😉

I thought you were using hires fix😂. If you use hires fix to generate this size directly you may need a of 4090 lol.

I only have the exe. And it doesn't matter if I use "Open with" or start the exe and pull the image into it. I hope you can fix this. 👍

Would you mind sending me a copy of your png? Zip it up and attach it here, or email it to me(receyuki@gmail.com). I can't reproduce this problem with my own large size png.

Woisek commented 1 year ago

I thought you were using hires fix😂.

No, that's not possible, unfortunately. For a dual wallpaper, I start with 960x300 with 2x Highres fix to 1920x600 and then again upscale 2x to the final 3840 x 1200. 🙂

If you use hires fix to generate this size directly you may need a of 4090 lol.

Yeah, my wish that I had one. 😳 But unfortunately ... no money for it right now. 😌

Here, take this wallpaper (4,69MB): 00000-S=1568935102-St=45-Sa=DPM++ 2M Karras-Cfg=7.zip

And the error as image: Zwischenablagebild

receyuki commented 1 year ago

Bad news, I still can't reproduce your error even with your image. Would you mind try this debug version and post screenshots of the cmd window and the app window? SD-Prompt-Reader-1.3.0-resize-image-debug.zip

Woisek commented 1 year ago

Strange ... What I have discovered now is as follows: Starting the exe: image can be processed (both, original and debug). Using "Open with" fails with above error (also both original and debug).

This is from starting the exe and pulled an image into it.

aspect_ratio 1.4222222222222223 self.scaling 1.0 A size= (560, 393) aspect_ratio 1.4222222222222223 self.scaling 1.0 A size= (560, 393) aspect_ratio 1.4222222222222223 self.scaling 1.0 A size= (560, 393) aspect_ratio 1.4222222222222223 self.scaling 1.0 A size= (560, 393) aspect_ratio 1.4222222222222223 self.scaling 1.0 A size= (560, 393)

🤔

receyuki commented 1 year ago

Bravo! That's the point! I reproduced the error using "Open with".

Woisek commented 1 year ago

Great! 🎉 So ... a solution is on the way ... ? 🤔

receyuki commented 1 year ago

Try this one. If it works, use it instead. I'll fix this bug in the next update, but the new executable won't be released any time soon.

SD-Prompt-Reader-1.3.0-fix-resize-image.zip

Woisek commented 1 year ago

Perfect! This is so great, now I can edit all my upscales with the proper data. Many thanks again! 🎉🎉👍👍