Skip to content

Commit 371b24b

Browse files
committed
Add extra img2img noise
1 parent f23e5ce commit 371b24b

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

modules/sd_samplers_kdiffusion.py

+4
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ def sample_img2img(self, p, x, noise, conditioning, unconditional_conditioning,
145145

146146
xi = x + noise * sigma_sched[0]
147147

148+
if opts.img2img_extra_noise > 0:
149+
p.extra_generation_params["Extra noise"] = opts.img2img_extra_noise
150+
xi += noise * opts.img2img_extra_noise
151+
148152
extra_params_kwargs = self.initialize(p)
149153
parameters = inspect.signature(self.func).parameters
150154

modules/sd_samplers_timesteps.py

+4
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ def sample_img2img(self, p, x, noise, conditioning, unconditional_conditioning,
103103

104104
xi = x * sqrt_alpha_cumprod + noise * sqrt_one_minus_alpha_cumprod
105105

106+
if opts.img2img_extra_noise > 0:
107+
p.extra_generation_params["Extra noise"] = opts.img2img_extra_noise
108+
xi += noise * opts.img2img_extra_noise * sqrt_alpha_cumprod
109+
106110
extra_params_kwargs = self.initialize(p)
107111
parameters = inspect.signature(self.func).parameters
108112

modules/shared_options.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@
166166

167167
options_templates.update(options_section(('img2img', "img2img"), {
168168
"inpainting_mask_weight": OptionInfo(1.0, "Inpainting conditioning mask strength", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}, infotext='Conditional mask weight'),
169-
"initial_noise_multiplier": OptionInfo(1.0, "Noise multiplier for img2img", gr.Slider, {"minimum": 0.5, "maximum": 1.5, "step": 0.01}, infotext='Noise multiplier'),
169+
"initial_noise_multiplier": OptionInfo(1.0, "Noise multiplier for img2img", gr.Slider, {"minimum": 0.0, "maximum": 1.5, "step": 0.001}, infotext='Noise multiplier'),
170+
"img2img_extra_noise": OptionInfo(0.0, "Extra noise multiplier for img2img and hires fix", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}, infotext='Extra noise').info("0 = disabled (default); should be lower than denoising strength"),
170171
"img2img_color_correction": OptionInfo(False, "Apply color correction to img2img results to match original colors."),
171172
"img2img_fix_steps": OptionInfo(False, "With img2img, do exactly the amount of steps the slider specifies.").info("normally you'd do less with less denoising"),
172173
"img2img_background_color": OptionInfo("#ffffff", "With img2img, fill transparent parts of the input image with this color.", ui_components.FormColorPicker, {}),

scripts/xyz_grid.py

+2
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ def __init__(self, *args, **kwargs):
241241
AxisOption("Eta", float, apply_field("eta")),
242242
AxisOption("Clip skip", int, apply_clip_skip),
243243
AxisOption("Denoising", float, apply_field("denoising_strength")),
244+
AxisOption("Initial noise multiplier", float, apply_field("initial_noise_multiplier")),
245+
AxisOption("Extra noise", float, apply_override("img2img_extra_noise")),
244246
AxisOptionTxt2Img("Hires upscaler", str, apply_field("hr_upscaler"), choices=lambda: [*shared.latent_upscale_modes, *[x.name for x in shared.sd_upscalers]]),
245247
AxisOptionImg2Img("Cond. Image Mask Weight", float, apply_field("inpainting_mask_weight")),
246248
AxisOption("VAE", str, apply_vae, cost=0.7, choices=lambda: ['None'] + list(sd_vae.vae_dict)),

0 commit comments

Comments
 (0)