comfyanonymous / ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.
https://www.comfy.org/
GNU General Public License v3.0
52.41k stars 5.53k forks source link

[bug] Ksampler error while try use LORA in inpaiting SDXL #3845

Closed Milor123 closed 3 months ago

Milor123 commented 3 months ago

Hi guys, I have a problem while try use nodes for inpainting in SDXL (with fooocus, brushnet or differential diffusion)

InpaintWorker.calculate_weight_patched() takes 4 positional arguments but 5 were given

What happend?

When execute the workflow for firts time, all work nice, but if I try change something of loader, like the checkpoint, keywords of prompt or lora settings, then the workflow will bugged and shows it

IMPORTANT NOTE: It only occurts while have load some LORA

[rgthree] Using rgthree's optimized recursive execution.
Requested to load SDXL
Loading 1 new model
!!! Exception during processing!!! InpaintWorker.calculate_weight_patched() takes 4 positional arguments but 5 were given
Traceback (most recent call last):
  File "/home/noe/Documentos/ComfyUI/execution.py", line 151, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/execution.py", line 81, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/execution.py", line 74, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/custom_nodes/efficiency-nodes-comfyui/efficiency_nodes.py", line 713, in sample
    samples, images, gifs, preview = process_latent_image(model, seed, steps, cfg, sampler_name, scheduler,
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/custom_nodes/efficiency-nodes-comfyui/efficiency_nodes.py", line 533, in process_latent_image
    samples = KSampler().sample(model, seed, steps, cfg, sampler_name, scheduler, positive, negative,
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/nodes.py", line 1355, in sample
    return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/nodes.py", line 1325, in common_ksampler
    samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/custom_nodes/ComfyUI-AnimateDiff-Evolved/animatediff/sampling.py", line 313, in motion_sample
    return orig_comfy_sample(model, noise, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/custom_nodes/ComfyUI-Impact-Pack/modules/impact/sample_error_enhancer.py", line 9, in informative_sample
    return original_sample(*args, **kwargs)  # This code helps interpret error messages that occur within exceptions but does not have any impact on other operations.
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/custom_nodes/ComfyUI-Advanced-ControlNet/adv_control/control_reference.py", line 47, in refcn_sample
    return orig_comfy_sample(model, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/custom_nodes/ComfyUI-Advanced-ControlNet/adv_control/utils.py", line 111, in uncond_multiplier_check_cn_sample
    return orig_comfy_sample(model, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/custom_nodes/comfyui-diffusion-cg/recenter.py", line 29, in sample_center
    return SAMPLE(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/comfy/sample.py", line 43, in sample
    samples = sampler.sample(noise, positive, negative, cfg=cfg, latent_image=latent_image, start_step=start_step, last_step=last_step, force_full_denoise=force_full_denoise, denoise_mask=noise_mask, sigmas=sigmas, callback=callback, disable_pbar=disable_pbar, seed=seed)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/comfy/samplers.py", line 794, in sample
    return sample(self.model, noise, positive, negative, cfg, self.device, sampler, sigmas, self.model_options, latent_image=latent_image, denoise_mask=denoise_mask, callback=callback, disable_pbar=disable_pbar, seed=seed)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/comfy/samplers.py", line 696, in sample
    return cfg_guider.sample(noise, latent_image, sampler, sigmas, denoise_mask, callback, disable_pbar, seed)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/comfy/samplers.py", line 673, in sample
    self.inner_model, self.conds, self.loaded_models = comfy.sampler_helpers.prepare_sampling(self.model_patcher, noise.shape, self.conds)
                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/comfy/sampler_helpers.py", line 64, in prepare_sampling
    comfy.model_management.load_models_gpu([model] + models, model.memory_required([noise_shape[0] * 2] + list(noise_shape[1:])) + inference_memory)
  File "/home/noe/Documentos/ComfyUI/comfy/model_management.py", line 464, in load_models_gpu
    cur_loaded_model = loaded_model.model_load(lowvram_model_memory, force_patch_weights=force_patch_weights)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/comfy/model_management.py", line 306, in model_load
    raise e
  File "/home/noe/Documentos/ComfyUI/comfy/model_management.py", line 302, in model_load
    self.real_model = self.model.patch_model(device_to=patch_model_to, patch_weights=load_weights)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/comfy/model_patcher.py", line 278, in patch_model
    self.patch_weight_to_device(key, device_to)
  File "/home/noe/Documentos/ComfyUI/comfy/model_patcher.py", line 259, in patch_weight_to_device
    out_weight = self.calculate_weight(self.patches[key], temp_weight, key).to(weight.dtype)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noe/Documentos/ComfyUI/custom_nodes/ComfyUI-Easy-Use/py/libs/fooocus.py", line 66, in calculate_weight_patched
    return self.original_calculate_weight(self, remaining, weight, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: InpaintWorker.calculate_weight_patched() takes 4 positional arguments but 5 were given

Prompt executed in 0.05 seconds

and the solution is kill comfyui python process and open again (the unload models dont solve my problem) OR DISABLE THE LORA :/

But it only happens with inpaiting models.

and the comfyui show the error in the ksampler (Note I've try with the normal Ksampler and get the same bug) image

Extra notes: The lora is for SDXL not inpaiting and the checkpoint are not inpaiting SDXL models

is not EASY nodes problem, in a normal nodes like this i have the same bug updated: this a problem easy nodes problem, caused by easy fooocus apply

image

ltdrdata commented 3 months ago

That is a issue of ComfyUI-Easy-Use. Update ComfyUI and ComfyUI-Easy-Use. And issue is persistent then report to that repo.

Milor123 commented 3 months ago

That is a issue of ComfyUI-Easy-Use. Update ComfyUI and ComfyUI-Easy-Use. And issue is persistent then report to that repo.

The bug persist. I've keep updated my custom nodes and comfyui bro, but its not bug of Easy-Nodes, because in this workflow i dont use EASY NODES

image

and I have the same problem

mamorett commented 3 months ago

I have the same identical problem. I am not using ComfyUI-Easy-Use. First run everything fine, second run gives the same error as described above. My workflow is using Fooocus inpainter nodes. image

If I remove LORA it works perfectly.

ltdrdata commented 3 months ago

That is a issue of ComfyUI-Easy-Use. Update ComfyUI and ComfyUI-Easy-Use. And issue is persistent then report to that repo.

The bug persist. I've keep updated my custom nodes and comfyui bro, but its not bug of Easy-Nodes, because in this workflow i dont use EASY NODES

image

and I have the same problem

It doesn't matter whether the node of Easy Use is used in your workflow. The Easy Use code is being executed.

And that is the error point.

  File "/home/noe/Documentos/ComfyUI/custom_nodes/ComfyUI-Easy-Use/py/libs/fooocus.py", line 66, in calculate_weight_patched
    return self.original_calculate_weight(self, remaining, weight, key)

To confirm that it is not an issue with Easy Use, you need to disable Easy Use (not just the node but the node pack) and reproduce the same error. Then, you should review the error trace from that execution.

mamorett commented 3 months ago

I can confirm, forcing the update of Easy Nodes fixes the issue for me.

Milor123 commented 3 months ago

@mcmonkey4eva you have reason, is a problem the Easy Nodes, and it is not fixed for me updating it. However if I replaced the easy apply fooocus and by the nodes of inpaint and now i dont have this bug, I will report it to the easy nodes.

Thank u very much, and I am sorry !