Fix KSamplerAdvanced with add_noise disabled on nested latents (#15447)
This commit is contained in:
parent
c2bcbecd82
commit
27bca654eb
|
|
@ -37,6 +37,11 @@ def prepare_noise(latent_image, seed, noise_inds=None):
|
|||
|
||||
return noises
|
||||
|
||||
def prepare_empty_noise(latent_image):
|
||||
if latent_image.is_nested:
|
||||
return comfy.nested_tensor.NestedTensor([torch.zeros_like(t, device="cpu") for t in latent_image.unbind()])
|
||||
return torch.zeros_like(latent_image, device="cpu")
|
||||
|
||||
def fix_empty_latent_channels(model, latent_image, downscale_ratio_spacial=None, downscale_ratio_temporal=None):
|
||||
if latent_image.is_nested:
|
||||
return latent_image
|
||||
|
|
|
|||
|
|
@ -718,15 +718,7 @@ class Noise_EmptyNoise:
|
|||
self.seed = 0
|
||||
|
||||
def generate_noise(self, input_latent):
|
||||
latent_image = input_latent["samples"]
|
||||
if latent_image.is_nested:
|
||||
tensors = latent_image.unbind()
|
||||
zeros = []
|
||||
for t in tensors:
|
||||
zeros.append(torch.zeros(t.shape, dtype=t.dtype, layout=t.layout, device="cpu"))
|
||||
return comfy.nested_tensor.NestedTensor(zeros)
|
||||
else:
|
||||
return torch.zeros(latent_image.shape, dtype=latent_image.dtype, layout=latent_image.layout, device="cpu")
|
||||
return comfy.sample.prepare_empty_noise(input_latent["samples"])
|
||||
|
||||
|
||||
class Noise_RandomNoise:
|
||||
|
|
|
|||
2
nodes.py
2
nodes.py
|
|
@ -1570,7 +1570,7 @@ def common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive,
|
|||
latent_image = comfy.sample.fix_empty_latent_channels(model, latent_image, latent.get("downscale_ratio_spacial", None), latent.get("downscale_ratio_temporal", None))
|
||||
|
||||
if disable_noise:
|
||||
noise = torch.zeros(latent_image.size(), dtype=latent_image.dtype, layout=latent_image.layout, device="cpu")
|
||||
noise = comfy.sample.prepare_empty_noise(latent_image)
|
||||
else:
|
||||
batch_inds = latent["batch_index"] if "batch_index" in latent else None
|
||||
noise = comfy.sample.prepare_noise(latent_image, seed, batch_inds)
|
||||
|
|
|
|||
Loading…
Reference in New Issue