JasonS09 / comfy_sd_krita_plugin

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

Image generation fails to arrive to the canvas #3

Closed notfood closed 1 year ago

notfood commented 1 year ago

Any workflow will fail with the following error

TypeError: arguments did not match any overloaded call:
  start(self, msec: int): argument 1 has unexpected type 'float'
  start(self): too many arguments

Additionally, live preview isn't showing anything, generation appears to be in the ComfyUI/Output folder.

To Reproduce Steps to reproduce the behavior:

  1. Go to txt2img dock
  2. Set it up and generate
  3. Wait for gen (check live)
  4. See error

Screenshots image

TypeError
Python 3.11.3: /usr/bin/python3
Fri Jul 28 12:09:38 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.

 /media/Makai/home/.local/share/krita/pykrita/krita_comfy/client.py in on_history_received(history_res={'fda29e90-398b-4d4f-b5ea-867de55cb34c': {'outputs': {'SaveImage': {'images': [{'filename': 'ComfyUI_00113_.png', 'subfolder': '', 'type': 'output'}]}}, 'prompt': [0, 'fda29e90-398b-4d4f-b5ea-867de55cb34c', {'3': {'class_type': 'KSampler', 'inputs': {'cfg': 7.0, 'denoise': 1.0, 'latent_image': [...], 'model': [...], 'negative': [...], 'positive': [...], 'sampler_name': 'euler', 'scheduler': 'simple', 'seed': 10198833846670115194, 'steps': 15}}, '6': {'class_type': 'CLIPTextEncode', 'inputs': {'clip': [...], 'text': 'a cat girl, best quality'}}, '7': {'class_type': 'CLIPTextEncode', 'inputs': {'clip': [...], 'text': 'worst quality, low quality'}}, 'CheckpointLoaderSimple': {'class_type': 'CheckpointLoaderSimple', 'inputs': {'ckpt_name': 'Anime/based64_v3.inpainting.safetensors'}}, 'ClipSetLastLayer': {'class_type': 'CLIPSetLastLayer', 'inputs': {'clip': [...], 'stop_at_clip_layer': -2}}, 'EmptyLatentImage': {'class_type': 'EmptyLatentImage', 'inputs': {'batch_size': 1, 'height': 512, 'width': 512}}, 'SaveImage': {'class_type': 'SaveImage', 'inputs': {'filename_prefix': 'ComfyUI', 'images': [...]}}, 'VAEDecode': {'class_type': 'VAEDecode', 'inputs': {'samples': [...], 'vae': [...]}}, 'VAELoader': {'class_type': 'VAELoader', 'inputs': {'vae_name': 'blessed2.vae.pt'}}}, {'client_id': '7d0f3bad-00ee-42f1-9d80-60202621b7d9'}, ['SaveImage']]}})
  256                 timer = QTimer()
  257                 timer.timeout.connect(check_if_populated)
  258                 timer.start(0.05)
  259 
  260         if status == STATE_DONE or skip_status_check:
timer = <PyQt5.QtCore.QTimer object>
timer.start = <built-in method start of QTimer object>
TypeError: arguments did not match any overloaded call:
  start(self, msec: int): argument 1 has unexpected type 'float'
  start(self): too many arguments
    __cause__ = None
    __class__ = <class 'TypeError'>
    __context__ = None
    __delattr__ = <method-wrapper '__delattr__' of TypeError object>
    __dict__ = {}
    __dir__ = <built-in method __dir__ of TypeError object>
    __doc__ = 'Inappropriate argument type.'
    __eq__ = <method-wrapper '__eq__' of TypeError object>
    __format__ = <built-in method __format__ of TypeError object>
    __ge__ = <method-wrapper '__ge__' of TypeError object>
    __getattribute__ = <method-wrapper '__getattribute__' of TypeError object>
    __getstate__ = <built-in method __getstate__ of TypeError object>
    __gt__ = <method-wrapper '__gt__' of TypeError object>
    __hash__ = <method-wrapper '__hash__' of TypeError object>
    __init__ = <method-wrapper '__init__' of TypeError object>
    __init_subclass__ = <built-in method __init_subclass__ of type object>
    __le__ = <method-wrapper '__le__' of TypeError object>
    __lt__ = <method-wrapper '__lt__' of TypeError object>
    __ne__ = <method-wrapper '__ne__' of TypeError object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <built-in method __reduce__ of TypeError object>
    __reduce_ex__ = <built-in method __reduce_ex__ of TypeError object>
    __repr__ = <method-wrapper '__repr__' of TypeError object>
    __setattr__ = <method-wrapper '__setattr__' of TypeError object>
    __setstate__ = <built-in method __setstate__ of TypeError object>
    __sizeof__ = <built-in method __sizeof__ of TypeError object>
    __str__ = <method-wrapper '__str__' of TypeError object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __suppress_context__ = False
    __traceback__ = <traceback object>
    add_note = <built-in method add_note of TypeError object>
    args = ("arguments did not match any overloaded call:\n  s...ed type 'float'\n  start(self): too many arguments",)
    with_traceback = <built-in method with_traceback of TypeError object>

The above is a description of an error in a Python program.  Here is
the original traceback:

Traceback (most recent call last):
  File "/media/Makai/home/.local/share/krita/pykrita/krita_comfy/client.py", line 258, in on_history_received
    timer.start(0.05)
TypeError: arguments did not match any overloaded call:
  start(self, msec: int): argument 1 has unexpected type 'float'
  start(self): too many arguments

Desktop:

JasonS09 commented 1 year ago

The live preview thing is expected. It used to do something when it was an Automatic1111 plugin, the tab is useless right now (but I've been too lazy to remove it).

As for the issue, can you tell me what version of Krita are you using? I can't reproduce but I've noticed the failing function is a built in function, not really part of the plugin's code.

notfood commented 1 year ago

Sorry, I forgot.

JasonS09 commented 1 year ago

I pushed some changes. Can you git pull, restart Krita and try again?

notfood commented 1 year ago

The error changed.

image

UnboundLocalError
Python 3.11.3: /usr/bin/python3
Fri Jul 28 12:51:52 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.

 /media/Makai/home/.local/share/krita/pykrita/krita_comfy/script.py in cb(response={'info': {}, 'outputs': ['iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAAA...o+5jtiQSQU0aH21N//z+JVRBPBJ528QAAAABJRU5ErkJggg==']})
  298 
  299             if self.cfg("hide_layers", bool):
  300                 for layer in layers[:-1]:
  301                     layer.setVisible(False)
  302 
layer undefined
layers undefined
UnboundLocalError: cannot access local variable 'layers' where it is not associated with a value
    __cause__ = None
    __class__ = <class 'UnboundLocalError'>
    __context__ = None
    __delattr__ = <method-wrapper '__delattr__' of UnboundLocalError object>
    __dict__ = {}
    __dir__ = <built-in method __dir__ of UnboundLocalError object>
    __doc__ = 'Local name referenced but not bound to a value.'
    __eq__ = <method-wrapper '__eq__' of UnboundLocalError object>
    __format__ = <built-in method __format__ of UnboundLocalError object>
    __ge__ = <method-wrapper '__ge__' of UnboundLocalError object>
    __getattribute__ = <method-wrapper '__getattribute__' of UnboundLocalError object>
    __getstate__ = <built-in method __getstate__ of UnboundLocalError object>
    __gt__ = <method-wrapper '__gt__' of UnboundLocalError object>
    __hash__ = <method-wrapper '__hash__' of UnboundLocalError object>
    __init__ = <method-wrapper '__init__' of UnboundLocalError object>
    __init_subclass__ = <built-in method __init_subclass__ of type object>
    __le__ = <method-wrapper '__le__' of UnboundLocalError object>
    __lt__ = <method-wrapper '__lt__' of UnboundLocalError object>
    __ne__ = <method-wrapper '__ne__' of UnboundLocalError object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <built-in method __reduce__ of UnboundLocalError object>
    __reduce_ex__ = <built-in method __reduce_ex__ of UnboundLocalError object>
    __repr__ = <method-wrapper '__repr__' of UnboundLocalError object>
    __setattr__ = <method-wrapper '__setattr__' of UnboundLocalError object>
    __setstate__ = <built-in method __setstate__ of UnboundLocalError object>
    __sizeof__ = <built-in method __sizeof__ of UnboundLocalError object>
    __str__ = <method-wrapper '__str__' of UnboundLocalError object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __suppress_context__ = False
    __traceback__ = <traceback object>
    add_note = <built-in method add_note of UnboundLocalError object>
    args = ("cannot access local variable 'layers' where it is not associated with a value",)
    name = None
    with_traceback = <built-in method with_traceback of UnboundLocalError object>

The above is a description of an error in a Python program.  Here is
the original traceback:

Traceback (most recent call last):
  File "/media/Makai/home/.local/share/krita/pykrita/krita_comfy/script.py", line 300, in cb
    for layer in layers[:-1]:
                 ^^^^^^
UnboundLocalError: cannot access local variable 'layers' where it is not associated with a value

image After dismissing the error: image

JasonS09 commented 1 year ago

I made a new push. Update, restart and try again. A new message will probably show up, can you show me what it says?

notfood commented 1 year ago

image

AssertionError
Python 3.11.3: /usr/bin/python3
Fri Jul 28 13:27:30 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.

 /media/Makai/home/.local/share/krita/pykrita/krita_comfy/script.py in cb(response={'info': {}, 'outputs': ['iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAAA...vgcdcq9H2l9LZ4LSssP8HTWIq5TMbw0AAAAAASUVORK5CYII=']})
  296             except Exception as e:
  297                 self.client.images_received.disconnect(cb)
  298                 assert False, e
  299                 return
  300 
e undefined
AssertionError: Raw data size: 1048576, Expected size: 16777216
    __cause__ = None
    __class__ = <class 'AssertionError'>
    __context__ = AssertionError('Raw data size: 1048576, Expected size: 16777216')
    __delattr__ = <method-wrapper '__delattr__' of AssertionError object>
    __dict__ = {}
    __dir__ = <built-in method __dir__ of AssertionError object>
    __doc__ = 'Assertion failed.'
    __eq__ = <method-wrapper '__eq__' of AssertionError object>
    __format__ = <built-in method __format__ of AssertionError object>
    __ge__ = <method-wrapper '__ge__' of AssertionError object>
    __getattribute__ = <method-wrapper '__getattribute__' of AssertionError object>
    __getstate__ = <built-in method __getstate__ of AssertionError object>
    __gt__ = <method-wrapper '__gt__' of AssertionError object>
    __hash__ = <method-wrapper '__hash__' of AssertionError object>
    __init__ = <method-wrapper '__init__' of AssertionError object>
    __init_subclass__ = <built-in method __init_subclass__ of type object>
    __le__ = <method-wrapper '__le__' of AssertionError object>
    __lt__ = <method-wrapper '__lt__' of AssertionError object>
    __ne__ = <method-wrapper '__ne__' of AssertionError object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <built-in method __reduce__ of AssertionError object>
    __reduce_ex__ = <built-in method __reduce_ex__ of AssertionError object>
    __repr__ = <method-wrapper '__repr__' of AssertionError object>
    __setattr__ = <method-wrapper '__setattr__' of AssertionError object>
    __setstate__ = <built-in method __setstate__ of AssertionError object>
    __sizeof__ = <built-in method __sizeof__ of AssertionError object>
    __str__ = <method-wrapper '__str__' of AssertionError object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __suppress_context__ = False
    __traceback__ = <traceback object>
    add_note = <built-in method add_note of AssertionError object>
    args = (AssertionError('Raw data size: 1048576, Expected size: 16777216'),)
    with_traceback = <built-in method with_traceback of AssertionError object>

The above is a description of an error in a Python program.  Here is
the original traceback:

Traceback (most recent call last):
  File "/media/Makai/home/.local/share/krita/pykrita/krita_comfy/script.py", line 292, in cb
    layers = [
             ^
  File "/media/Makai/home/.local/share/krita/pykrita/krita_comfy/script.py", line 293, in <listcomp>
    insert(name if name else f"{mode} {i + 1}", output)
  File "/media/Makai/home/.local/share/krita/pykrita/krita_comfy/script.py", line 260, in insert
    assert expected == size, f"Raw data size: {size}, Expected size: {expected}"
           ^^^^^^^^^^^^^^^^
AssertionError: Raw data size: 1048576, Expected size: 16777216

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/media/Makai/home/.local/share/krita/pykrita/krita_comfy/script.py", line 298, in cb
    assert False, e
AssertionError: Raw data size: 1048576, Expected size: 16777216
JasonS09 commented 1 year ago

Are you selecting the whole canvas? If not, can you try again but with the whole canvas selected?

notfood commented 1 year ago

I had nothing selected. It works when I select something. image

JasonS09 commented 1 year ago

Yes, that error is a product of a data check the previous mantainers had put in the code and sometimes (mostly always) it kicks when you don't have anything selected. Honestly I don't know exactly what purpose does it have and I'm debating with myself if I should just remove it.

In the meantime, I recommend to always select before generating something, unless you're upscaling or importing your last ComfyUI generation (which I made to skip the data check). If you want to work with the whole canvas, simply make a whole selection on it. Remember to set upscaler in Common Options tab if you want to work with bigger sizes and don't have base/max size disabled, otherwise the image will be plain resized and lose a lot of quality.

notfood commented 1 year ago

Thanks!

JoseConseco commented 11 months ago

Thx for info about - having to select canvast for imgToImg to work. Btw, it would be great if plugin would detect that no pixels were selected, and it would select it for us @JasonS09