JasonS09 / comfy_sd_krita_plugin

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

Generation errors with ControlNet #9

Closed notfood closed 1 year ago

notfood commented 1 year ago

If you enable ControlNet, generation will error but ultimately work after dismissing the error.

Additionally, ControlNet preview fails with the same error. I suspect it's only the preview failing to load.

To Reproduce

  1. Go to ControlNet dock
  2. Enable ControlNet 1 and configure it
  3. Generate under the Text2Image dock
  4. See error

Screenshots image

AttributeError
Python 3.11.3: /usr/bin/python3
Mon Jul 31 11:31:31 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': {'all_names': ['ComfyUI_00117_.png'], 'cfg_scale': 8.0, 'negative_prompt': 'worst quality, low quality', 'prompt': 'a chibi fox girl, best quality', 'sampler_name': 'euler', 'sd_model': 'Anime/breakdomainanime_A0440.safetensors', 'steps': 15}, 'outputs': ['iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAAA...HnBSle15RkYmxEQLj/wddxjELbrYXIwAAAABJRU5ErkJggg==']})
  419             assert response is not None, "Backend Error, check terminal"
  420             output = response["outputs"]
  421             pixmap = QPixmap.fromImage(b64_to_img(output))
  422             self.controlnet_preview_annotator_received.emit(pixmap)
  423 
pixmap undefined
global QPixmap = <class 'PyQt5.QtGui.QPixmap'>
QPixmap.fromImage = <built-in function fromImage>
global b64_to_img = <function b64_to_img>
output = ['iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAAA...HnBSle15RkYmxEQLj/wddxjELbrYXIwAAAABJRU5ErkJggg==']

 /media/Makai/home/.local/share/krita/pykrita/krita_comfy/utils.py in b64_to_img(enc=['iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAAA...HnBSle15RkYmxEQLj/wddxjELbrYXIwAAAABJRU5ErkJggg=='])
  195 def b64_to_img(enc: str):
  196     """Converts base64-encoded string to QImage"""
  197     ba = QByteArray.fromBase64(enc.encode("utf-8"))
  198     return QImage.fromData(ba) #Removed explicit format to support other image formats.
  199 
ba undefined
global QByteArray = <class 'PyQt5.QtCore.QByteArray'>
QByteArray.fromBase64 = <built-in function fromBase64>
enc = ['iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAAA...HnBSle15RkYmxEQLj/wddxjELbrYXIwAAAABJRU5ErkJggg==']
enc.encode undefined
AttributeError: 'list' object has no attribute 'encode'
    __cause__ = None
    __class__ = <class 'AttributeError'>
    __context__ = None
    __delattr__ = <method-wrapper '__delattr__' of AttributeError object>
    __dict__ = {}
    __dir__ = <built-in method __dir__ of AttributeError object>
    __doc__ = 'Attribute not found.'
    __eq__ = <method-wrapper '__eq__' of AttributeError object>
    __format__ = <built-in method __format__ of AttributeError object>
    __ge__ = <method-wrapper '__ge__' of AttributeError object>
    __getattribute__ = <method-wrapper '__getattribute__' of AttributeError object>
    __getstate__ = <built-in method __getstate__ of AttributeError object>
    __gt__ = <method-wrapper '__gt__' of AttributeError object>
    __hash__ = <method-wrapper '__hash__' of AttributeError object>
    __init__ = <method-wrapper '__init__' of AttributeError object>
    __init_subclass__ = <built-in method __init_subclass__ of type object>
    __le__ = <method-wrapper '__le__' of AttributeError object>
    __lt__ = <method-wrapper '__lt__' of AttributeError object>
    __ne__ = <method-wrapper '__ne__' of AttributeError object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <built-in method __reduce__ of AttributeError object>
    __reduce_ex__ = <built-in method __reduce_ex__ of AttributeError object>
    __repr__ = <method-wrapper '__repr__' of AttributeError object>
    __setattr__ = <method-wrapper '__setattr__' of AttributeError object>
    __setstate__ = <built-in method __setstate__ of AttributeError object>
    __sizeof__ = <built-in method __sizeof__ of AttributeError object>
    __str__ = <method-wrapper '__str__' of AttributeError object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __suppress_context__ = False
    __traceback__ = <traceback object>
    add_note = <built-in method add_note of AttributeError object>
    args = ("'list' object has no attribute 'encode'",)
    name = 'encode'
    obj = ['iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAAA...HnBSle15RkYmxEQLj/wddxjELbrYXIwAAAABJRU5ErkJggg==']
    with_traceback = <built-in method with_traceback of AttributeError 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 421, in cb
    pixmap = QPixmap.fromImage(b64_to_img(output))
                               ^^^^^^^^^^^^^^^^^^
  File "/media/Makai/home/.local/share/krita/pykrita/krita_comfy/utils.py", line 197, in b64_to_img
    ba = QByteArray.fromBase64(enc.encode("utf-8"))
                               ^^^^^^^^^^
AttributeError: 'list' object has no attribute 'encode'

Desktop:

JasonS09 commented 1 year ago

Hey. I made a new push. Can you check if the issue is solved?

notfood commented 1 year ago

Works! Thank you!