blueturtleai / krita-stable-diffusion

MIT License
43 stars 3 forks source link

An error occurred: 'NoneType' object has no attribute 'setsize' #1

Closed sonalys closed 1 year ago

sonalys commented 1 year ago

I receive this error when generating any image

An error occurred: 'NoneType' object has no attribute 'setsize'
blueturtleai commented 1 year ago

Which Krita version do you use? Do I guess right, this happens when you use the generation mode "img -> img"? Has the document the size 512x512, color mode "RGB/Alpha" and color depth "8 bit"?

blueturtleai commented 1 year ago

Is there a visible layer, which shows the init image?

All this is checked before starting generate, but I want to make sure, that it doesn't slip through the check and it causes the problem.

blueturtleai commented 1 year ago

I checked it and saw, it could also happen in generation mode "text -> image". If you used this mode, you don't need an init image in a visible layer.

sonalys commented 1 year ago

I use version 5.1.1 I used text -> img 512x512 rgba with 8 bit depth

blueturtleai commented 1 year ago

Could you please either post a screenshot of the dialog, so I can see all values you used or send me the used values? If it happens with any prompt, I don’t need the prompt.

blueturtleai commented 1 year ago

If you use an apikey, please hide it on a screenshot

blueturtleai commented 1 year ago

Forgot to ask: which OS do you use?

blueturtleai commented 1 year ago

If you prefer, you can send me the screenshot or the details also via pm on Twitter https://twitter.com/BlueTurtleAI or Reddit u/BlueTurtleAI

blueturtleai commented 1 year ago

@klausweiss You reacted with thumb up to the initial post of this issue. Does this mean, you have got the same problem? If so, it would be great if you could help fixing this problem. Unfortunately, the author of this issue doesn't give me more details.

sonalys commented 1 year ago

I use arch linux

no api key

I cant show it today, since I am not home

blueturtleai commented 1 year ago

Okay, thanks for the update. Would be great, if you could send me more details, when you are at home again.

klausweiss commented 1 year ago

Hey @blueturtleai. Yup, same issue, Manjaro Linux (arch-based), with API key though.

I tried debugging it. QImage couldn't be loaded here https://github.com/blueturtleai/krita-stable-diffusion/blob/b70246905918942eca40d36070ff31629b808909/krita_stablehorde/krita_stablehorde.py#L345 ^ this returned False. I checked the bytes array and it was valid. Dumped it to a file and firefox could open it as a .webp image no prob.

blueturtleai commented 1 year ago

Thanks for the details @klausweiss ! That’s really strange, especially bcs you can open the image manually. It seems to be a general problem, perhaps specific for Linux. So, do i guess right, it happens with different prompts you tried? Do you have the chance to try it on another computer with a different OS?

klausweiss commented 1 year ago

I had actually tried with 1.1.1. before. Yeah, happens with all prompts I've tried.

I did some more digging. Opened a standalone python interpreter and tried loading a .webp image. Same results.

>>> from PyQt5.QtGui import QImage
>>> with open("/tmp/img.webp", "rb") as f: QImage.fromData(f.read()).byteCount()
0

With a jpeg image it's a different story. Loads no prob.

>>> from PyQt5.QtGui import QImage
>>> with open("/tmp/img.jpg", "rb") as f: QImage.fromData(f.read()).byteCount()
63332864

I guess the arch distribution of pyqt (or qt?) was not compiled with libwebp support.

If we want it to be robust, we could convert the webp bytes to a png and try loading again, if loading from webp bytes fails.

blueturtleai commented 1 year ago

Many thanks for your tests and your findings! I will talk to the stablehorde guys and ask, if it’s possible to receive the images as jpg or png.

blueturtleai commented 1 year ago

Running sudo pacman -S qt5-imageformats should fix the problem. Please let me know, if it works afterwards.

klausweiss commented 1 year ago

Ayy, this solves the issue for me! Thank you! (:

blueturtleai commented 1 year ago

That’s great!

sonalys commented 1 year ago

worked for me, thanks!

blueturtleai commented 1 year ago

Okay, great! I added a hint for Linux users to the readme how to check, if Qt5 webp is supported and how to add support. Additionally I will check in a new version, if webp is supported and show a hint how to add support.