JasonS09 / comfy_sd_krita_plugin

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

Crashing after clicking "Run this workflow" #41

Closed wizcas closed 8 months ago

wizcas commented 9 months ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Open the Workflow panel
  2. Input the default workflow, which is
    {
    "3": {
        "class_type": "KSampler",
        "inputs": {
            "cfg": 7.0,
            "denoise": 0.3,
            "model": [
                "4",
                0
            ],
            "latent_image": [
                "VAEEncode",
                0
            ],
            "negative": [
                "7",
                0
            ],
            "positive": [
                "6",
                0
            ],
            "sampler_name": "ddim",
            "scheduler": "ddim_uniform",
            "seed": 13101924985762230254,
            "steps": 20
        }
    },
    "4": {
        "class_type": "CheckpointLoaderSimple",
        "inputs": {
            "ckpt_name": "SD1.5\\dreamshaper_8.safetensors"
        }
    },
    "6": {
        "class_type": "CLIPTextEncode",
        "inputs": {
            "clip": [
                "ClipSetLastLayer",
                0
            ],
            "text": ""
        }
    },
    "7": {
        "class_type": "CLIPTextEncode",
        "inputs": {
            "clip": [
                "ClipSetLastLayer",
                0
            ],
            "text": ""
        }
    },
    "8": {
        "class_type": "VAEDecode",
        "inputs": {
            "samples": [
                "3",
                0
            ],
            "vae": [
                "4",
                2
            ]
        }
    },
    "9": {
        "class_type": "SaveImage",
        "inputs": {
            "filename_prefix": "ComfyUI",
            "images": [
                "8",
                0
            ]
        }
    },
    "ClipSetLastLayer": {
        "class_type": "CLIPSetLastLayer",
        "inputs": {
            "stop_at_clip_layer": -1,
            "clip": [
                "4",
                1
            ]
        }
    },
    "LoadBase64Image": {
        "class_type": "LoadBase64Image",
        "inputs": {
            "image": "<<PrunedImageData>>"
        }
    },
    "VAEEncode": {
        "class_type": "VAEEncode",
        "inputs": {
            "pixels": [
                "LoadBase64Image",
                0
            ],
            "vae": [
                "4",
                2
            ]
        }
    }
    }
  3. Click "Run this workflow"
  4. It shows a message box with error

Screenshots image

Desktop (please complete the following information):

Additional context

AssertionError
Python 3.10.7: D:\Krita (x64)\bin\krita.exe
Wed Dec 20 23:40:32 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\chen\AppData\Roaming\krita\pykrita\krita_comfy\pages\workflow.py in <lambda>()
   69         self.import_images.released.connect(script.action_get_last_images)
   70         self.run_this_workflow.released.connect(
   71             lambda: script.action_run_workflow(script.cfg("workflow", str))
   72         )
   73         self.workflow.textChanged.connect(
global script = <krita_comfy.script.Script object>
script.action_run_workflow = <bound method Script.action_run_workflow of <krita_comfy.script.Script object>>
script.cfg = <krita_comfy.config.Config object>
builtinstr = <class 'str'>

 C:\Users\chen\AppData\Roaming\krita\pykrita\krita_comfy\script.py in action_run_workflow(self=<krita_comfy.script.Script object>, workflow='{\n    "3": {\n        "class_type": "KSampler",\n ...                2\n            ]\n        }\n    }\n}')
  639             return
  640         self.adjust_selection()
  641         self.apply_run_workflow(workflow)
  642 
  643     def action_update_controlnet_config(self):
self = <krita_comfy.script.Script object>
self.apply_run_workflow = <bound method Script.apply_run_workflow of <krita_comfy.script.Script object>>
workflow = '{\n    "3": {\n        "class_type": "KSampler",\n ...                2\n            ]\n        }\n    }\n}'

 C:\Users\chen\AppData\Roaming\krita\pykrita\krita_comfy\script.py in apply_run_workflow(self=<krita_comfy.script.Script object>, workflow='{\n    "3": {\n        "class_type": "KSampler",\n ...                2\n            ]\n        }\n    }\n}')
  497     def apply_run_workflow(self, workflow):
  498         # freeze selection region
  499         mode = self.cfg("workflow_to", str)
  500         is_inpaint = mode == "inpaint"
  501         #is_upscale = self.cfg("workflow_to", str) == "upscale"
mode undefined
self = <krita_comfy.script.Script object>
self.cfg = <krita_comfy.config.Config object>
builtinstr = <class 'str'>

 C:\Users\chen\AppData\Roaming\krita\pykrita\krita_comfy\config.py in __call__(self=<krita_comfy.config.Config object>, key='workflow_to', type=<class 'str'>)
   34     def __call__(self, key: str, type: type = str):
   35         """Shorthand for Config.get()"""
   36         return self.get(key, type)
   37 
   38     def get(self, key: str, type: type = str):
self = <krita_comfy.config.Config object>
self.get = <bound method Config.get of <krita_comfy.config.Config object>>
key = 'workflow_to'
type = <class 'str'>

 C:\Users\chen\AppData\Roaming\krita\pykrita\krita_comfy\config.py in get(self=<krita_comfy.config.Config object>, key='workflow_to', type=<class 'str'>)
   50             # notably QSettings assume strings too unless specified
   51             if self.model is not None:
   52                 assert self.config.contains(key) and hasattr(
   53                     self.model, key
   54                 ), ERR_MISSING_CONFIG
self = <krita_comfy.config.Config object>
self.config = <PyQt5.QtCore.QSettings object>
self.config.contains = <built-in method contains of QSettings object>
key = 'workflow_to'
builtinhasattr = <built-in function hasattr>
self.model = Defaults(base_url='http://127.0.0.1:8188', creat...9_input_image='', controlnet9_pixel_perfect=True)
global ERR_MISSING_CONFIG = 'Report this bug, developer missed out a config key somewhere.'
AssertionError: Report this bug, developer missed out a config key somewhere.
    __cause__ = None
    __class__ = <class 'AssertionError'>
    __context__ = None
    __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>
    __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>
    args = ('Report this bug, developer missed out a config key somewhere.',)
    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 "C:\Users\chen\AppData\Roaming\krita\pykrita\krita_comfy\pages\workflow.py", line 71, in <lambda>
    lambda: script.action_run_workflow(script.cfg("workflow", str))
  File "C:\Users\chen\AppData\Roaming\krita\pykrita\krita_comfy\script.py", line 641, in action_run_workflow
    self.apply_run_workflow(workflow)
  File "C:\Users\chen\AppData\Roaming\krita\pykrita\krita_comfy\script.py", line 499, in apply_run_workflow
    mode = self.cfg("workflow_to", str)
  File "C:\Users\chen\AppData\Roaming\krita\pykrita\krita_comfy\config.py", line 36, in __call__
    return self.get(key, type)
  File "C:\Users\chen\AppData\Roaming\krita\pykrita\krita_comfy\config.py", line 52, in get
    assert self.config.contains(key) and hasattr(
AssertionError: Report this bug, developer missed out a config key somewhere.
JasonS09 commented 8 months ago

There have been some structural changes in the plugin, I admit the run workflow functionality has not been my priority lately so those bugs are expected.

Can you check if it's working properly now?

wizcas commented 8 months ago

@JasonS09 Thanks for the update and the fast response! Yes, there's no error messages now. Running the default workflow leads to an empty result, though. I presume there might be something wrong with the default workflow. 🤔 I'll keep playing around.