From 56f8a6b081e3dbfc93956e5c44e507e74a2ba040 Mon Sep 17 00:00:00 2001 From: catboxanon <122327233+catboxanon@users.noreply.github.com> Date: Sun, 16 Apr 2023 20:34:52 -0400 Subject: [PATCH 1/5] Fix sampler schedules with step multiplier --- modules/processing.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/processing.py b/modules/processing.py index 6d9c6a8d..f6514637 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -639,8 +639,12 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed: processed = Processed(p, [], p.seed, "") file.write(processed.infotext(p, 0)) - uc = get_conds_with_caching(prompt_parser.get_learned_conditioning, negative_prompts, p.steps, cached_uc) - c = get_conds_with_caching(prompt_parser.get_multicond_learned_conditioning, prompts, p.steps, cached_c) + try: + step_multiplier = 2 if sd_samplers.all_samplers_map.get(p.sampler_name).aliases[0] in ['k_dpmpp_2s_a', 'k_dpmpp_2s_a_ka', 'k_dpmpp_sde', 'k_dpmpp_sde_ka', 'k_dpm_2', 'k_dpm_2_a', 'k_heun'] else 1 + except: + step_multiplier = 1 + uc = get_conds_with_caching(prompt_parser.get_learned_conditioning, negative_prompts, p.steps * step_multiplier, cached_uc) + c = get_conds_with_caching(prompt_parser.get_multicond_learned_conditioning, prompts, p.steps * step_multiplier, cached_c) if len(model_hijack.comments) > 0: for comment in model_hijack.comments: From 81b276a1ea943fc177c7ec16b272eec7bccb62f7 Mon Sep 17 00:00:00 2001 From: catboxanon <122327233+catboxanon@users.noreply.github.com> Date: Sun, 16 Apr 2023 20:39:18 -0400 Subject: [PATCH 2/5] Add second order samplers compat option --- modules/shared.py | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/shared.py b/modules/shared.py index 5fd0eecb..e1d4088f 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -338,6 +338,7 @@ options_templates.update(options_section(('compatibility', "Compatibility"), { "use_old_karras_scheduler_sigmas": OptionInfo(False, "Use old karras scheduler sigmas (0.1 to 10)."), "no_dpmpp_sde_batch_determinism": OptionInfo(False, "Do not make DPM++ SDE deterministic across different batch sizes."), "use_old_hires_fix_width_height": OptionInfo(False, "For hires fix, use width/height sliders to set final resolution rather than first pass (disables Upscale by, Resize width/height to)."), + "fix_second_order_samplers_schedule": OptionInfo(False, "Fix prompt schedule for second order samplers."), })) options_templates.update(options_section(('interrogate', "Interrogate Options"), { From 4d0c8163036b42dd66aad922c22d3b3d19217bd9 Mon Sep 17 00:00:00 2001 From: catboxanon <122327233+catboxanon@users.noreply.github.com> Date: Sun, 16 Apr 2023 20:39:45 -0400 Subject: [PATCH 3/5] Modify step multiplier flow --- modules/processing.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/processing.py b/modules/processing.py index f6514637..15ad629f 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -639,10 +639,12 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed: processed = Processed(p, [], p.seed, "") file.write(processed.infotext(p, 0)) - try: - step_multiplier = 2 if sd_samplers.all_samplers_map.get(p.sampler_name).aliases[0] in ['k_dpmpp_2s_a', 'k_dpmpp_2s_a_ka', 'k_dpmpp_sde', 'k_dpmpp_sde_ka', 'k_dpm_2', 'k_dpm_2_a', 'k_heun'] else 1 - except: - step_multiplier = 1 + step_multiplier = 1 + if shared.opts.fix_second_order_samplers_schedule: + try: + step_multiplier = 2 if sd_samplers.all_samplers_map.get(p.sampler_name).aliases[0] in ['k_dpmpp_2s_a', 'k_dpmpp_2s_a_ka', 'k_dpmpp_sde', 'k_dpmpp_sde_ka', 'k_dpm_2', 'k_dpm_2_a', 'k_heun'] else 1 + except: + pass uc = get_conds_with_caching(prompt_parser.get_learned_conditioning, negative_prompts, p.steps * step_multiplier, cached_uc) c = get_conds_with_caching(prompt_parser.get_multicond_learned_conditioning, prompts, p.steps * step_multiplier, cached_c) From 234fa9a57da00d3f549ea43348ab664665fc275e Mon Sep 17 00:00:00 2001 From: catboxanon <122327233+catboxanon@users.noreply.github.com> Date: Sun, 16 Apr 2023 21:06:22 -0400 Subject: [PATCH 4/5] Update shared.py --- modules/shared.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/shared.py b/modules/shared.py index e1d4088f..6f13ec52 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -338,7 +338,7 @@ options_templates.update(options_section(('compatibility', "Compatibility"), { "use_old_karras_scheduler_sigmas": OptionInfo(False, "Use old karras scheduler sigmas (0.1 to 10)."), "no_dpmpp_sde_batch_determinism": OptionInfo(False, "Do not make DPM++ SDE deterministic across different batch sizes."), "use_old_hires_fix_width_height": OptionInfo(False, "For hires fix, use width/height sliders to set final resolution rather than first pass (disables Upscale by, Resize width/height to)."), - "fix_second_order_samplers_schedule": OptionInfo(False, "Fix prompt schedule for second order samplers."), + "dont_fix_second_order_samplers_schedule": OptionInfo(False, "Do not fix prompt schedule for second order samplers."), })) options_templates.update(options_section(('interrogate', "Interrogate Options"), { From 9de7298898951d6038eeadee78f7be3b09d2cfc3 Mon Sep 17 00:00:00 2001 From: catboxanon <122327233+catboxanon@users.noreply.github.com> Date: Sun, 16 Apr 2023 21:06:37 -0400 Subject: [PATCH 5/5] Update processing.py --- modules/processing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/processing.py b/modules/processing.py index 15ad629f..2f391ee4 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -640,7 +640,7 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed: file.write(processed.infotext(p, 0)) step_multiplier = 1 - if shared.opts.fix_second_order_samplers_schedule: + if not shared.opts.dont_fix_second_order_samplers_schedule: try: step_multiplier = 2 if sd_samplers.all_samplers_map.get(p.sampler_name).aliases[0] in ['k_dpmpp_2s_a', 'k_dpmpp_2s_a_ka', 'k_dpmpp_sde', 'k_dpmpp_sde_ka', 'k_dpm_2', 'k_dpm_2_a', 'k_heun'] else 1 except: