ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

Unable to run KSampler after Inpaint, AttributeError: 'NoneType' object has no attribute 'shape'

Open belladoreai opened this issue 1 year ago • 4 comments

It seems that inpainting with KSampler causes something from the mask to get "left over" into the latent output from KSampler. Running another KSampler on the output then breaks with AttributeError: 'NoneType' object has no attribute 'shape'.

Is there any way to remove mask after inpainting?

Here is an image of how I was trying to remove mask after inpainting, but it didn't help, still getting the error.

As another workaround, I also tried to use the Remove Noise Mask node from ImpactPack, but that didn't work either. temp555

ERROR:root:!!! Exception during processing !!!
ERROR:root:Traceback (most recent call last):
File "C:\Programs\ComfyUI\ComfyUI\execution.py", line 152, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Programs\ComfyUI\ComfyUI\execution.py", line 82, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Programs\ComfyUI\ComfyUI\execution.py", line 75, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Programs\ComfyUI\ComfyUI\nodes.py", line 1375, in sample
return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Programs\ComfyUI\ComfyUI\nodes.py", line 1345, in common_ksampler
samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Programs\ComfyUI\ComfyUI\comfy\sample.py", line 100, in sample
samples = sampler.sample(noise, positive_copy, negative_copy, 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 "C:\Programs\ComfyUI\ComfyUI\comfy\samplers.py", line 712, 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 "C:\Programs\ComfyUI\ComfyUI\comfy\samplers.py", line 602, in sample
positive = encode_model_conds(model.extra_conds, positive, noise, device, "positive", latent_image=latent_image, denoise_mask=denoise_mask, seed=seed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Programs\ComfyUI\ComfyUI\comfy\samplers.py", line 498, in encode_model_conds
out = model_function(**params)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Programs\ComfyUI\ComfyUI\comfy\model_base.py", line 117, in extra_conds
if len(denoise_mask.shape) == len(noise.shape):
^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'shape'

belladoreai avatar Feb 06 '24 19:02 belladoreai

The issue might be due to this commit; Add InpaintModelConditioning node.

the inpaint model fails when generating images from text. Let's wait for the author to fix it.

Of course, if you are in a hurry, you can wrap the code between lines 112 and 123 with a conditional statement to avoid the error: if denoise_mask is not None and noise is not None:

HelloClyde avatar Feb 07 '24 22:02 HelloClyde

@HelloClyde Thank you for provided the code snippet I needed to fix this! Have you notified the developer about this simple fix?

uraniumcrystalsmaster avatar Feb 12 '24 02:02 uraniumcrystalsmaster

@HelloClyde Thank you for provided the code snippet I needed to fix this! Have you notified the developer about this simple fix?

@comfyanonymous Can you help with a quick fix for this issue?

HelloClyde avatar Feb 13 '24 15:02 HelloClyde

The issue might be due to this commit; Add InpaintModelConditioning node.

the inpaint model fails when generating images from text. Let's wait for the author to fix it.

Of course, if you are in a hurry, you can wrap the code between lines 112 and 123 with a conditional statement to avoid the error: if denoise_mask is not None and noise is not None:

This solution worked for me. Thanks. image

ShawnZeng avatar Feb 17 '24 14:02 ShawnZeng

The issue might be due to this commit; Add InpaintModelConditioning node.

the inpaint model fails when generating images from text. Let's wait for the author to fix it.

Of course, if you are in a hurry, you can wrap the code between lines 112 and 123 with a conditional statement to avoid the error: if denoise_mask is not None and noise is not None:

The lines needed to be changed every update are now between lines 117 to 129 and will continue to change so remember the block the if statement need to contain has the first line: if concat_latent_image.shape[1:] != noise.shape[1:]:

and last line: denoise_mask = utils.resize_to_batch_size(denoise_mask.round(), noise.shape[0])

uraniumcrystalsmaster avatar Feb 21 '24 08:02 uraniumcrystalsmaster

@comfyanonymous seems that this problem has not been fixed yet?

zyseu avatar Mar 25 '24 09:03 zyseu

The author has already fixed this issue. You just need to update your version of ComfyUI to the commit "94a5a67" or later.

HelloClyde avatar Apr 15 '24 03:04 HelloClyde

The author has already fixed this issue.

Thanks for the heads up. I didn't test it myself but I'll take your word for it and close this.

belladoreai avatar Apr 15 '24 12:04 belladoreai

I am the latest version, but I still have this issue

catto123455 avatar Aug 08 '24 07:08 catto123455

I am the latest version, but I still have this issue

Me too

Erika1408 avatar Aug 09 '24 08:08 Erika1408

the same here :)

WasamiKirua avatar Aug 09 '24 17:08 WasamiKirua

same here

axelblaze88 avatar Aug 09 '24 18:08 axelblaze88

Can you see if it's fixed with the latest commits?

comfyanonymous avatar Aug 09 '24 18:08 comfyanonymous

yes, now is working for me 👏🏼

axelblaze88 avatar Aug 13 '24 11:08 axelblaze88