From 72377b02518f96051a01a7e0ea30a6a14d8ec1de Mon Sep 17 00:00:00 2001 From: Kohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com> Date: Tue, 23 May 2023 23:48:23 +0800 Subject: [PATCH] Use type to determine if it is enable --- modules/generation_parameters_copypaste.py | 1 - modules/sd_samplers_kdiffusion.py | 6 +++--- modules/shared.py | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/generation_parameters_copypaste.py b/modules/generation_parameters_copypaste.py index c92fb0fbf..e98866fce 100644 --- a/modules/generation_parameters_copypaste.py +++ b/modules/generation_parameters_copypaste.py @@ -318,7 +318,6 @@ infotext_to_setting_name_mapping = [ ('Conditional mask weight', 'inpainting_mask_weight'), ('Model hash', 'sd_model_checkpoint'), ('ENSD', 'eta_noise_seed_delta'), - ('Enable Custom KDiffusion Schedule', 'custom_k_sched'), ('KDiffusion Scheduler Type', 'k_sched_type'), ('KDiffusion Scheduler sigma_max', 'sigma_max'), ('KDiffusion Scheduler sigma_min', 'sigma_min'), diff --git a/modules/sd_samplers_kdiffusion.py b/modules/sd_samplers_kdiffusion.py index 5fea08b0c..eff2e32d4 100644 --- a/modules/sd_samplers_kdiffusion.py +++ b/modules/sd_samplers_kdiffusion.py @@ -46,6 +46,7 @@ sampler_extra_params = { k_diffusion_samplers_map = {x.name: x for x in samplers_data_k_diffusion} k_diffusion_scheduler = { + 'None': None, 'karras': k_diffusion.sampling.get_sigmas_karras, 'exponential': k_diffusion.sampling.get_sigmas_exponential, 'polyexponential': k_diffusion.sampling.get_sigmas_polyexponential @@ -295,8 +296,7 @@ class KDiffusionSampler: k_diffusion.sampling.torch = TorchHijack(self.sampler_noises if self.sampler_noises is not None else []) - if opts.custom_k_sched: - p.extra_generation_params["Enable Custom KDiffusion Schedule"] = True + if opts.k_sched_type != "None": p.extra_generation_params["KDiffusion Scheduler Type"] = opts.k_sched_type p.extra_generation_params["KDiffusion Scheduler sigma_max"] = opts.sigma_max p.extra_generation_params["KDiffusion Scheduler sigma_min"] = opts.sigma_min @@ -325,7 +325,7 @@ class KDiffusionSampler: if p.sampler_noise_scheduler_override: sigmas = p.sampler_noise_scheduler_override(steps) - elif opts.custom_k_sched: + elif opts.k_sched_type != "None": sigma_min, sigma_max = (0.1, 10) if opts.use_old_karras_scheduler_sigmas else (self.model_wrap.sigmas[0].item(), self.model_wrap.sigmas[-1].item()) sigmas_func = k_diffusion_scheduler[opts.k_sched_type] sigmas_kwargs = { diff --git a/modules/shared.py b/modules/shared.py index a0e762d2a..b24f52dd4 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -517,8 +517,7 @@ options_templates.update(options_section(('sampler-params', "Sampler parameters" 's_churn': OptionInfo(0.0, "sigma churn", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}), 's_tmin': OptionInfo(0.0, "sigma tmin", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}), 's_noise': OptionInfo(1.0, "sigma noise", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}), - 'custom_k_sched': OptionInfo(False, "Enable Custom KDiffusion Scheduler"), - 'k_sched_type': OptionInfo("karras", "scheduler type", gr.Dropdown, {"choices": ["karras", "exponential", "polyexponential"]}), + 'k_sched_type': OptionInfo("default", "scheduler type", gr.Dropdown, {"choices": ["None", "karras", "exponential", "polyexponential"]}), 'sigma_max': OptionInfo(0.0, "sigma max", gr.Number).info("the maximum noise strength for the scheduler. Set to 0 to use the same value which 'xxx karras' samplers use."), 'sigma_min': OptionInfo(0.0, "sigma min", gr.Number).info("the minimum noise strength for the scheduler. Set to 0 to use the same value which 'xxx karras' samplers use."), 'rho': OptionInfo(7.0, "rho", gr.Number).info("higher will make a more steep noise scheduler (decrease faster). default for karras is 7.0, for polyexponential is 1.0"),