WASasquatch / was-node-suite-comfyui

An extensive node suite for ComfyUI with over 210 new nodes
MIT License
1.22k stars 177 forks source link

Latent Upscale by Factor Crashing #51

Closed marcussacana closed 1 year ago

marcussacana commented 1 year ago

I noticied with some scaling factor values, the comfy crash with this error

Traceback (most recent call last):
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\execution.py", line 184, in execute
    executed += recursive_execute(self.server, prompt, self.outputs, x, extra_data)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\execution.py", line 60, in recursive_execute
    executed += recursive_execute(server, prompt, outputs, input_unique_id, extra_data)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\execution.py", line 60, in recursive_execute
    executed += recursive_execute(server, prompt, outputs, input_unique_id, extra_data)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\execution.py", line 60, in recursive_execute
    executed += recursive_execute(server, prompt, outputs, input_unique_id, extra_data)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\execution.py", line 69, in recursive_execute
    outputs[unique_id] = getattr(obj, obj.FUNCTION)(**input_data_all)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\nodes.py", line 841, in sample
    return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\nodes.py", line 810, in common_ksampler
    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)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\comfy\samplers.py", line 581, in sample
    samples = getattr(k_diffusion_sampling, "sample_{}".format(self.sampler))(self.model_k, noise, sigmas, extra_args=extra_args)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\python_embeded\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\comfy\k_diffusion\sampling.py", line 594, in sample_dpmpp_2m
    denoised = model(x, sigmas[i] * s_in, **extra_args)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\python_embeded\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\comfy\samplers.py", line 277, in forward
    out = self.inner_model(x, sigma, cond=cond, uncond=uncond, cond_scale=cond_scale, cond_concat=cond_concat, model_options=model_options)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\python_embeded\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\comfy\k_diffusion\external.py", line 114, in forward
    eps = self.get_eps(input * c_in, self.sigma_to_t(sigma), **kwargs)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\comfy\k_diffusion\external.py", line 140, in get_eps
    return self.inner_model.apply_model(*args, **kwargs)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\comfy\samplers.py", line 265, in apply_model
    out = sampling_function(self.inner_model.apply_model, x, timestep, uncond, cond, cond_scale, cond_concat, model_options=model_options)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\comfy\samplers.py", line 244, in sampling_function
    cond, uncond = calc_cond_uncond_batch(model_function, cond, uncond, x, timestep, max_total_area, cond_concat, model_options)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\comfy\samplers.py", line 221, in calc_cond_uncond_batch
    output = model_function(input_x, timestep_, cond=c).chunk(batch_chunks)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\comfy\ldm\models\diffusion\ddpm.py", line 859, in apply_model
    x_recon = self.model(x_noisy, t, **cond)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\python_embeded\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\comfy\ldm\models\diffusion\ddpm.py", line 1337, in forward    out = self.diffusion_model(x, t, context=cc, control=control, transformer_options=transformer_options)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\python_embeded\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Users\Marcus\Documents\Ferramentas\ComfyUI\ComfyUI\comfy\ldm\modules\diffusionmodules\openaimodel.py", line 816, in forward
    h = th.cat([h, hsp], dim=1)
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 24 but got size 23 for tensor number 1 in the list

Is there a way to prevent this? the input latent size it was 896w x 448h + 1.5 upscale

WASasquatch commented 1 year ago

This error is not coming from latent upscale by factor, but the sampler.

I tried 1.5 on a few images, and can't reproduce. Probably a sampler settings that's incompatible with resolution.

I'd report to ComfyUI.

marcussacana commented 1 year ago

Currently I was able to manually emulate the scale factor with math like this, so is fine if for now image

WASasquatch commented 1 year ago

Could also use the Image Resize (and use Rescale mode) node which does same math to ensure a multiple of 8.

If it's a HR pass, you can use the Image Size to Number to get the width/height after to do math on.