aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-08-15 09:50:20 +0300
committerGitHub <noreply@github.com>2023-08-15 09:50:20 +0300
commitbc61ad9ec8cece0dc4ad445ee29abf4e9305f2df (patch)
treeb4aa6ca6232790900923c05370bdafeef5e41de0 /modules
parent79d4e81984171a047d6c71d97a67dda7dd87c43c (diff)
parent371b24b17c1cf98c9068a4b585b93cc1610702dc (diff)
Merge pull request #12564 from catboxanon/feat/img2img-noise
Add extra noise param for img2img operations
Diffstat (limited to 'modules')
-rw-r--r--modules/sd_samplers_kdiffusion.py4
-rw-r--r--modules/sd_samplers_timesteps.py4
-rw-r--r--modules/shared_options.py3
3 files changed, 10 insertions, 1 deletions
diff --git a/modules/sd_samplers_kdiffusion.py b/modules/sd_samplers_kdiffusion.py
index 08b9e740..08866e41 100644
--- a/modules/sd_samplers_kdiffusion.py
+++ b/modules/sd_samplers_kdiffusion.py
@@ -145,6 +145,10 @@ class KDiffusionSampler(sd_samplers_common.Sampler):
xi = x + noise * sigma_sched[0]
+ if opts.img2img_extra_noise > 0:
+ p.extra_generation_params["Extra noise"] = opts.img2img_extra_noise
+ xi += noise * opts.img2img_extra_noise
+
extra_params_kwargs = self.initialize(p)
parameters = inspect.signature(self.func).parameters
diff --git a/modules/sd_samplers_timesteps.py b/modules/sd_samplers_timesteps.py
index 66e83ff7..68aea454 100644
--- a/modules/sd_samplers_timesteps.py
+++ b/modules/sd_samplers_timesteps.py
@@ -104,6 +104,10 @@ class CompVisSampler(sd_samplers_common.Sampler):
xi = x * sqrt_alpha_cumprod + noise * sqrt_one_minus_alpha_cumprod
+ if opts.img2img_extra_noise > 0:
+ p.extra_generation_params["Extra noise"] = opts.img2img_extra_noise
+ xi += noise * opts.img2img_extra_noise * sqrt_alpha_cumprod
+
extra_params_kwargs = self.initialize(p)
parameters = inspect.signature(self.func).parameters
diff --git a/modules/shared_options.py b/modules/shared_options.py
index fc0de61f..79cbb92e 100644
--- a/modules/shared_options.py
+++ b/modules/shared_options.py
@@ -166,7 +166,8 @@ For img2img, VAE is used to process user's input image before the sampling, and
options_templates.update(options_section(('img2img', "img2img"), {
"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'),
- "initial_noise_multiplier": OptionInfo(1.0, "Noise multiplier for img2img", gr.Slider, {"minimum": 0.5, "maximum": 1.5, "step": 0.01}, infotext='Noise multiplier'),
+ "initial_noise_multiplier": OptionInfo(1.0, "Noise multiplier for img2img", gr.Slider, {"minimum": 0.0, "maximum": 1.5, "step": 0.001}, infotext='Noise multiplier'),
+ "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"),
"img2img_color_correction": OptionInfo(False, "Apply color correction to img2img results to match original colors."),
"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"),
"img2img_background_color": OptionInfo("#ffffff", "With img2img, fill transparent parts of the input image with this color.", ui_components.FormColorPicker, {}),