Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where using DisableNoise or disabling add_noise results in non-deterministic generations #5306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions comfy_extras/nodes_custom_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,6 @@ def get_sampler(self, order, rtol, atol, h_init, pcoeff, icoeff, dcoeff, accept_
"s_noise":s_noise })
return (sampler, )

class Noise_EmptyNoise:
def __init__(self):
self.seed = 0

def generate_noise(self, input_latent):
latent_image = input_latent["samples"]
return torch.zeros(latent_image.shape, dtype=latent_image.dtype, layout=latent_image.layout, device="cpu")


class Noise_RandomNoise:
def __init__(self, seed):
self.seed = seed
Expand Down Expand Up @@ -360,7 +351,7 @@ def sample(self, model, add_noise, noise_seed, cfg, positive, negative, sampler,
latent = latent_image
latent_image = latent["samples"]
if not add_noise:
noise = Noise_EmptyNoise().generate_noise(latent)
raise ValueError("add_noise must be enabled")
else:
noise = Noise_RandomNoise(noise_seed).generate_noise(latent)

Expand Down Expand Up @@ -480,7 +471,7 @@ def INPUT_TYPES(s):
CATEGORY = "sampling/custom_sampling/noise"

def get_noise(self):
return (Noise_EmptyNoise(),)
raise RuntimeError("DisableNoise cannot be used")


class RandomNoise(DisableNoise):
Expand Down
6 changes: 3 additions & 3 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ class KSamplerAdvanced:
def INPUT_TYPES(s):
return {"required":
{"model": ("MODEL",),
"add_noise": (["enable", "disable"], ),
"add_noise": (["enable"], ),
"noise_seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
"steps": ("INT", {"default": 20, "min": 1, "max": 10000}),
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0, "step":0.1, "round": 0.01}),
Expand All @@ -1373,8 +1373,8 @@ def sample(self, model, add_noise, noise_seed, steps, cfg, sampler_name, schedul
if return_with_leftover_noise == "enable":
force_full_denoise = False
disable_noise = False
if add_noise == "disable":
disable_noise = True
if add_noise != "enable":
raise ValueError("add_noise must be enabled")
return common_ksampler(model, noise_seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise, disable_noise=disable_noise, start_step=start_at_step, last_step=end_at_step, force_full_denoise=force_full_denoise)

class SaveImage:
Expand Down
Loading