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

Add noisy latent to ExtraNoiseParams for callback #12856

Merged
Merged
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
7 changes: 5 additions & 2 deletions modules/script_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ def __init__(self, image, p, filename, pnginfo):


class ExtraNoiseParams:
def __init__(self, noise, x):
def __init__(self, noise, x, xi):
self.noise = noise
"""Random noise generated by the seed"""

self.x = x
"""Latent image representation of the image"""
"""Latent representation of the image"""

self.xi = xi
"""Noisy latent representation of the image"""


class CFGDenoiserParams:
Expand Down
2 changes: 1 addition & 1 deletion modules/sd_samplers_kdiffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def sample_img2img(self, p, x, noise, conditioning, unconditional_conditioning,

if opts.img2img_extra_noise > 0:
p.extra_generation_params["Extra noise"] = opts.img2img_extra_noise
extra_noise_params = ExtraNoiseParams(noise, x)
extra_noise_params = ExtraNoiseParams(noise, x, xi)
extra_noise_callback(extra_noise_params)
noise = extra_noise_params.noise
xi += noise * opts.img2img_extra_noise
Expand Down
2 changes: 1 addition & 1 deletion modules/sd_samplers_timesteps.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def sample_img2img(self, p, x, noise, conditioning, unconditional_conditioning,

if opts.img2img_extra_noise > 0:
p.extra_generation_params["Extra noise"] = opts.img2img_extra_noise
extra_noise_params = ExtraNoiseParams(noise, x)
extra_noise_params = ExtraNoiseParams(noise, x, xi)
extra_noise_callback(extra_noise_params)
noise = extra_noise_params.noise
xi += noise * opts.img2img_extra_noise * sqrt_alpha_cumprod
Expand Down