JasonS09 / comfy_sd_krita_plugin

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

I can`t load the workflow. #2

Closed sergiogbrox closed 1 year ago

sergiogbrox commented 1 year ago

Describe the bug When I click to load the workflow in the Krita plugin, it gives an error.

JSONDecodeError Python 3.8.1: C:\Program Files\Krita (x64)\bin\krita.exe Fri Jul 28 09:27:33 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\sergi\AppData\Roaming\krita\pykrita\krita_comfy\pages\workflow.py in () 71 self.import_images.released.connect(script.action_get_last_images) 72 self.run_this_workflow.released.connect( 73 lambda: script.action_run_workflow(script.cfg(f"{self.prefix}_workflow", str)) 74 ) 75 self.workflow.textChanged.connect( global script = script.action_run_workflow = <bound method Script.action_run_workflow of > script.cfg = builtinstr = <class 'str'>

C:\Users\sergi\AppData\Roaming\krita\pykrita\krita_comfy\script.py in action_run_workflow(self=, workflow='') 608 return 609 self.adjust_selection() 610 self.apply_run_workflow(workflow) 611 612 def action_update_controlnet_config(self): self = self.apply_run_workflow = <bound method Script.apply_run_workflow of > workflow = ''

C:\Users\sergi\AppData\Roaming\krita\pykrita\krita_comfy\script.py in apply_run_workflow(self=, workflow='') 485 mask_image = sel_image = self.get_selection_image() 486 487 self.client.run_workflow(workflow, sel_image, mask_image, cb) 488 489 def apply_get_last_images(self): self = self.client = self.client.run_workflow = <bound method Client.run_workflow of > workflow = '' sel_image = mask_image = cb = <function Script.basic_callback_crafter..cb>

C:\Users\sergi\AppData\Roaming\krita\pykrita\krita_comfy\client.py in run_workflow(self=, workflow='', src_img=, mask=, cb=<function Script.basic_callback_crafter..cb>) 1568 1569 def run_workflow(self, workflow, src_img, mask, cb=None): 1570 params = self.restore_params(json.loads(workflow), src_img, mask) 1571 self.get_images(params, cb) 1572 params undefined self = self.restore_params = <bound method Client.restore_params of > global json = <module 'json' from 'C:\Program Files\Krita (x64)\python\python38.zip\json\init.pyc'> json.loads = workflow = '' src_img = mask =

C:\Users\sergi\AppData\Local\Pitikapp Remote Dashboard\json__init__.py in loads(s='', cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw={})

C:\Users\sergi\AppData\Local\Pitikapp Remote Dashboard\json\decoder.py in decode(self=, s='', _w=)

C:\Users\sergi\AppData\Local\Pitikapp Remote Dashboard\json\decoder.py in raw_decode(self=, s='', idx=0)

JSONDecodeError: Expecting value: line 1 column 1 (char 0) cause = None class = <class 'json.decoder.JSONDecodeError'> context = StopIteration(0) delattr = <method-wrapper 'delattr' of JSONDecodeError object> dict = {'colno': 1, 'doc': '', 'lineno': 1, 'msg': 'Expecting value', 'pos': 0} dir = doc = None eq = <method-wrapper 'eq' of JSONDecodeError object> format = ge = <method-wrapper 'ge' of JSONDecodeError object> getattribute = <method-wrapper 'getattribute' of JSONDecodeError object> gt = <method-wrapper 'gt' of JSONDecodeError object> hash = <method-wrapper 'hash' of JSONDecodeError object> init = <bound method JSONDecodeError.init of JSONDe...ror('Expecting value: line 1 column 1 (char 0)')> init_subclass = <built-in method init_subclass of type object> le = <method-wrapper 'le' of JSONDecodeError object> lt = <method-wrapper 'lt' of JSONDecodeError object> module = 'json.decoder' ne = <method-wrapper 'ne' of JSONDecodeError object> new = reduce = <bound method JSONDecodeError.reduce of JSON...ror('Expecting value: line 1 column 1 (char 0)')> reduce_ex = <built-in method reduce_ex of JSONDecodeError object> repr = <method-wrapper 'repr' of JSONDecodeError object> setattr = <method-wrapper 'setattr' of JSONDecodeError object> setstate = sizeof = str = <method-wrapper 'str' of JSONDecodeError object> subclasshook = __suppress_context = True traceback = weakref__ = None args = ('Expecting value: line 1 column 1 (char 0)',) colno = 1 doc = '' lineno = 1 msg = 'Expecting value' pos = 0 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\sergi\AppData\Roaming\krita\pykrita\krita_comfy\pages\workflow.py", line 73, in lambda: script.action_run_workflow(script.cfg(f"{self.prefix}_workflow", str)) File "C:\Users\sergi\AppData\Roaming\krita\pykrita\krita_comfy\script.py", line 610, in action_run_workflow self.apply_run_workflow(workflow) File "C:\Users\sergi\AppData\Roaming\krita\pykrita\krita_comfy\script.py", line 487, in apply_run_workflow self.client.run_workflow(workflow, sel_image, mask_image, cb) File "C:\Users\sergi\AppData\Roaming\krita\pykrita\krita_comfy\client.py", line 1570, in run_workflow params = self.restore_params(json.loads(workflow), src_img, mask) File "json__init__.py", line 357, in loads File "json\decoder.py", line 337, in decode File "json\decoder.py", line 355, in raw_decode json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

To Reproduce Steps to reproduce the behavior: workflow / workflow to text2img / run this work flow / See error

Screenshots imagem_2023-07-28_093222233

imagem_2023-07-28_093411733

Desktop (please complete the following information):

Additional context plz help me s2

JasonS09 commented 1 year ago

To Reproduce Steps to reproduce the behavior: workflow / workflow to text2img / run this work flow / See error

It appears you're trying to run the workflow when it's empty. If you want to load a custom workflow to be run in Krita, follow these steps. The button you probably want to press is this one:

Screenshot 2023-07-28 070658

Alternatively, you can go to: txt2img tab -> click "Get Workflow" button

A workflow with your current settings will be automatically generated. You can then edit it in the text editor or elsewhere.

"Run this workflow" button uses what's in the textbox as input.

Note: make sure the workflow you want to import is in API format. Normal workflows exported directly from ComfyUI won't work, that's why we use Get Prompt node instead of a normal export.

sergiogbrox commented 1 year ago

@JasonS09 do you have any example workflows to recommend? Sorry, I'm having a bit of difficulty with this.

JasonS09 commented 1 year ago

@JasonS09 do you have any example workflows to recommend? Sorry, I'm having a bit of difficulty with this.

If you're not familiar with workflows and nodes in ComfyUI, I suggest you to stick with the basic usage of this tool (txt2img, img2img, inpainting, upscaling and controlnet). You can do all of that by simply using the UI like you would in other canvas oriented UIs. The plugin will take care to automatically build the workflow under the hood so you don't have to.

Running/injecting custom workflows is for more specific situations where you want some behaviour changed on all your subsequent generations. Like if you need a custom node applied to them, or want to increase the steps of the KSampler during the upscaling pass (you're unable to do that from the UI).

You don't need to know workflows to use this tool. That said, is there any specific workflow you're attempting to incorporate? Maybe I can help crafting one if you need.

sergiogbrox commented 1 year ago

ok @JasonS09, now I understand how the pre-programmed workflows in the extension work, but when I load the txt2img, it gives the following error:

TypeError Python 3.8.1: C:\Program Files\Krita (x64)\bin\krita.exe Tue Aug 1 08:46:27 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\sergi\AppData\Roaming\krita\pykrita\krita_comfy\pages\workflow.py in () 71 self.import_images.released.connect(script.action_get_last_images) 72 self.run_this_workflow.released.connect( 73 lambda: script.action_run_workflow(script.cfg(f"{self.prefix}_workflow", str)) 74 ) 75 self.workflow.textChanged.connect( global script = script.action_run_workflow = <bound method Script.action_run_workflow of > script.cfg = builtinstr = <class 'str'>

C:\Users\sergi\AppData\Roaming\krita\pykrita\krita_comfy\script.py in action_run_workflow(self=, workflow='{\n "last_node_id": 11,\n "last_link_id": 9,...onfig": {},\n "extra": {},\n "version": 0.4\n}') 610 return 611 self.adjust_selection() 612 self.apply_run_workflow(workflow) 613 614 def action_update_controlnet_config(self): self = self.apply_run_workflow = <bound method Script.apply_run_workflow of > workflow = '{\n "last_node_id": 11,\n "last_link_id": 9,...onfig": {},\n "extra": {},\n "version": 0.4\n}'

C:\Users\sergi\AppData\Roaming\krita\pykrita\krita_comfy\script.py in apply_run_workflow(self=, workflow='{\n "last_node_id": 11,\n "last_link_id": 9,...onfig": {},\n "extra": {},\n "version": 0.4\n}') 487 mask_image = sel_image = self.get_selection_image() 488 489 self.client.run_workflow(workflow, sel_image, mask_image, cb) 490 491 def apply_get_last_images(self): self = self.client = self.client.run_workflow = <bound method Client.run_workflow of > workflow = '{\n "last_node_id": 11,\n "last_link_id": 9,...onfig": {},\n "extra": {},\n "version": 0.4\n}' sel_image = mask_image = cb = <function Script.basic_callback_crafter..cb>

C:\Users\sergi\AppData\Roaming\krita\pykrita\krita_comfy\client.py in run_workflow(self=, workflow='{\n "last_node_id": 11,\n "last_link_id": 9,...onfig": {},\n "extra": {},\n "version": 0.4\n}', src_img=, mask=, cb=<function Script.basic_callback_crafter..cb>) 1584 1585 def run_workflow(self, workflow, src_img, mask, cb=None): 1586 params = self.restore_params(json.loads(workflow), src_img, mask) 1587 self.get_images(params, cb) 1588 params undefined self = self.restore_params = <bound method Client.restore_params of > global json = <module 'json' from 'C:\Program Files\Krita (x64)\python\python38.zip\json\init.pyc'> json.loads = workflow = '{\n "last_node_id": 11,\n "last_link_id": 9,...onfig": {},\n "extra": {},\n "version": 0.4\n}' src_img = mask =

C:\Users\sergi\AppData\Roaming\krita\pykrita\krita_comfy\client.py in restore_params(self=, params={'config': {}, 'extra': {}, 'groups': [], 'last_link_id': 9, 'last_node_id': 11, 'links': [[1, 4, 0, 3, 0, 'MODEL'], [2, 5, 0, 3, 3, 'LATENT'], [3, 4, 1, 6, 0, 'CLIP'], [4, 6, 0, 3, 1, 'CONDITIONING'], [5, 4, 1, 7, 0, 'CLIP'], [6, 7, 0, 3, 2, 'CONDITIONING'], [7, 3, 0, 8, 0, 'LATENT'], [8, 4, 2, 8, 1, 'VAE']], 'nodes': [{'flags': {}, 'id': 7, 'inputs': [{'link': 5, 'name': 'clip', 'type': 'CLIP'}], 'mode': 0, 'order': 4, 'outputs': [{'links': [6], 'name': 'CONDITIONING', 'slot_index': 0, 'type': 'CONDITIONING'}], 'pos': [413, 389], 'properties': {'Node name for S&R': 'CLIPTextEncode'}, 'size': {'0': 425.27801513671875, '1': 180.6060791015625}, 'type': 'CLIPTextEncode', ...}, {'flags': {}, 'id': 6, 'inputs': [{'link': 3, 'name': 'clip', 'type': 'CLIP'}], 'mode': 0, 'order': 3, 'outputs': [{'links': [4], 'name': 'CONDITIONING', 'slot_index': 0, 'type': 'CONDITIONING'}], 'pos': [415, 186], 'properties': {'Node name for S&R': 'CLIPTextEncode'}, 'size': {'0': 422.84503173828125, '1': 164.31304931640625}, 'type': 'CLIPTextEncode', ...}, {'flags': {}, 'id': 3, 'inputs': [{'link': 1, 'name': 'model', 'type': 'MODEL'}, {'link': 4, 'name': 'positive', 'type': 'CONDITIONING'}, {'link': 6, 'name': 'negative', 'type': 'CONDITIONING'}, {'link': 2, 'name': 'latent_image', 'type': 'LATENT'}], 'mode': 0, 'order': 5, 'outputs': [{'links': [7], 'name': 'LATENT', 'slot_index': 0, 'type': 'LATENT'}], 'pos': [863, 186], 'properties': {'Node name for S&R': 'KSampler'}, 'size': {'0': 315, '1': 262}, 'type': 'KSampler', ...}, {'flags': {}, 'id': 4, 'mode': 0, 'order': 0, 'outputs': [{'links': [1], 'name': 'MODEL', 'slot_index': 0, 'type': 'MODEL'}, {'links': [3, 5], 'name': 'CLIP', 'slot_index': 1, 'type': 'CLIP'}, {'links': [8], 'name': 'VAE', 'slot_index': 2, 'type': 'VAE'}], 'pos': [26, 474], 'properties': {'Node name for S&R': 'CheckpointLoaderSimple'}, 'size': {'0': 315, '1': 98}, 'type': 'CheckpointLoaderSimple', 'widgets_values': ['CinematicDiffusion-syberart-512px.ckpt']}, {'flags': {}, 'id': 8, 'inputs': [{'link': 7, 'name': 'samples', 'type': 'LATENT'}, {'link': 8, 'name': 'vae', 'type': 'VAE'}], 'mode': 0, 'order': 6, 'outputs': [{'links': [], 'name': 'IMAGE', 'slot_index': 0, 'type': 'IMAGE'}], 'pos': [1209, 188], 'properties': {'Node name for S&R': 'VAEDecode'}, 'size': {'0': 210, '1': 46}, 'type': 'VAEDecode'}, {'flags': {}, 'id': 5, 'mode': 0, 'order': 1, 'outputs': [{'links': [2], 'name': 'LATENT', 'slot_index': 0, 'type': 'LATENT'}], 'pos': [922, 619], 'properties': {'Node name for S&R': 'EmptyLatentImage'}, 'size': {'0': 315, '1': 106}, 'type': 'EmptyLatentImage', 'widgets_values': [512, 512, 1]}, {'flags': {}, 'id': 11, 'mode': 0, 'order': 2, 'pos': [1398, 328], 'properties': {'Node name for S&R': 'Get Prompt'}, 'size': {'0': 315, '1': 58}, 'type': 'Get Prompt', 'widgets_values': ['print to console']}], 'version': 0.4}, src_img=, mask=) 1570 workflow_image_data = self.cfg("workflow_img_data", dict)[mode] 1571 for node_id, node in params.items(): 1572 if node["class_type"] in ["LoadBase64Image", "LoadBase64ImageMask"]: 1573 for input_key, input_value in node["inputs"].items(): 1574 if workflow_image_data is not None and input_value == PRUNED_DATA and \ node = 11 TypeError: 'int' object is not subscriptable cause = None class = <class 'TypeError'> context = None delattr = <method-wrapper 'delattr' of TypeError object> dict = {} dir = doc = 'Inappropriate argument type.' eq = <method-wrapper 'eq' of TypeError object> format = ge = <method-wrapper 'ge' of TypeError object> getattribute = <method-wrapper 'getattribute' 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 = reduce = 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 = sizeof = str = <method-wrapper 'str' of TypeError object> subclasshook = __suppress_context = False traceback__ = args = ("'int' object is not subscriptable",) 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\sergi\AppData\Roaming\krita\pykrita\krita_comfy\pages\workflow.py", line 73, in lambda: script.action_run_workflow(script.cfg(f"{self.prefix}_workflow", str)) File "C:\Users\sergi\AppData\Roaming\krita\pykrita\krita_comfy\script.py", line 612, in action_run_workflow self.apply_run_workflow(workflow) File "C:\Users\sergi\AppData\Roaming\krita\pykrita\krita_comfy\script.py", line 489, in apply_run_workflow self.client.run_workflow(workflow, sel_image, mask_image, cb) File "C:\Users\sergi\AppData\Roaming\krita\pykrita\krita_comfy\client.py", line 1586, in run_workflow params = self.restore_params(json.loads(workflow), src_img, mask) File "C:\Users\sergi\AppData\Roaming\krita\pykrita\krita_comfy\client.py", line 1572, in restore_params if node["class_type"] in ["LoadBase64Image", "LoadBase64ImageMask"]: TypeError: 'int' object is not subscriptable

image

JasonS09 commented 1 year ago

You're trying to load a workflow for ComfyUI, those are not supported. It expects a workflow in API format. To get one, follow these steps .