JasonS09 / comfy_sd_krita_plugin

Make AI art between canvas and nodes with Krita.
MIT License
148 stars 7 forks source link

`AssertionError` when running txt2img #32

Closed space-nuko closed 9 months ago

space-nuko commented 10 months ago

Describe the bug I just installed the plugin, loaded my model and hit Start txt2img, then this happens

Details

``` AssertionError Python 3.10.7: C:\Program Files\Krita (x64)\bin\krita.exe Wed Nov 1 16:24:48 2023 A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred. C:\Users\a\AppData\Roaming\krita\pykrita\krita_comfy\script.py in cb(response=PromptResponse(mode='txt2img', sd_model='...=[Base64Image: PyQt5.QtCore.QSize(512, 512)])) 313 except TypeError: 314 pass 315 assert False, e 316 317 if self.cfg("hide_layers", bool): e undefined AssertionError: Raw data size: 1048576, Expected size: 4194304 __cause__ = None __class__ = __context__ = AssertionError('Raw data size: 1048576, Expected size: 4194304') __delattr__ = __dict__ = {} __dir__ = __doc__ = 'Assertion failed.' __eq__ = __format__ = __ge__ = __getattribute__ = __gt__ = __hash__ = __init__ = __init_subclass__ = __le__ = __lt__ = __ne__ = __new__ = __reduce__ = __reduce_ex__ = __repr__ = __setattr__ = __setstate__ = __sizeof__ = __str__ = __subclasshook__ = __suppress_context__ = False __traceback__ = args = (AssertionError('Raw data size: 1048576, Expected size: 4194304'),) with_traceback = The above is a description of an error in a Python program. Here is the original traceback: Traceback (most recent call last): File "C:\Users\a\AppData\Roaming\krita\pykrita\krita_comfy\script.py", line 306, in cb layers = [ File "C:\Users\a\AppData\Roaming\krita\pykrita\krita_comfy\script.py", line 307, in insert(name if name else f"{mode} {i + 1}", output) File "C:\Users\a\AppData\Roaming\krita\pykrita\krita_comfy\script.py", line 274, in insert assert expected == size, f"Raw data size: {size}, Expected size: {expected}" AssertionError: Raw data size: 1048576, Expected size: 4194304 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\a\AppData\Roaming\krita\pykrita\krita_comfy\script.py", line 315, in cb assert False, e AssertionError: Raw data size: 1048576, Expected size: 4194304 ```

However I figured out, if you check Disable base/max size or select the canvas then the error stops happening. But it was very confusing since nothing mentions it in the readme

To Reproduce Steps to reproduce the behavior:

  1. Go to txt2img
  2. Click Start txt2img
  3. See error

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

JasonS09 commented 10 months ago

Yes, you should always select the canvas before generating an image. Reason: https://github.com/JasonS09/comfy_sd_krita_plugin/issues/3#issuecomment-1656184249

space-nuko commented 10 months ago

Okay maybe best to show a popup in that case instead of throwing an error? Or remove the limitation if it makes more sense?

JasonS09 commented 10 months ago

Okay maybe best to show a popup in that case instead of throwing an error? Or remove the limitation if it makes more sense?

Actually someone suggested to automatically select the canvas if not done. I think that's the best way to handle the issue. I'll be working on it, should push the change soon.

ElliottLester commented 10 months ago

I thought it was just checking they were the same size but the input/output gets rounded to the nearest 8px. when there is a selection we resize can we just always resize to the canvas size? (i didn't look too closely at the code)

JasonS09 commented 10 months ago

Actually I think I can see the intention of the previous mantainer with this. If we totally removed the requirement then upscaling wouldn't work. It's no longer required for txt2img and img2img after this new push.