From 8d9188af6fbe672b089d1f5c46c37351bd09682e Mon Sep 17 00:00:00 2001 From: Alexandre Froger Date: Tue, 9 May 2023 21:13:12 +0800 Subject: [PATCH 1/5] Update sd_samplers.py [Issue]: UniPC always here #822 check if the samplers list is empty, in which case force only UniPC and PLMS, otherwise only use the set of selected ones, with PLMS forced as part of the set of available samplers --- modules/sd_samplers.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/sd_samplers.py b/modules/sd_samplers.py index eeaa66d9d..8f74dbe7d 100644 --- a/modules/sd_samplers.py +++ b/modules/sd_samplers.py @@ -32,7 +32,13 @@ def set_samplers(): global samplers, samplers_for_img2img shown_img2img = set(shared.opts.show_samplers) - shown = set(shared.opts.show_samplers + ['PLMS', 'UniPC']) + + if len(shared.opts.show_samplers) == 0: + shown = set(['UniPC']) + else: + shown = set(shared.opts.show_samplers) + + shown.add('PLMS') samplers = [x for x in all_samplers if x.name in shown] samplers_for_img2img = [x for x in all_samplers if x.name in shown_img2img] From 2d7e9bdf546fd1a74c065ad0be9b1ab4444ea0be Mon Sep 17 00:00:00 2001 From: Alexandre Froger Date: Tue, 9 May 2023 21:16:07 +0800 Subject: [PATCH 2/5] Update shared.py [Issue]: UniPC always here #822 remove PLMS from the samplers that can be selected/deselected since it should always be available --- modules/shared.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/shared.py b/modules/shared.py index 5065559ee..7c985b9f3 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -424,7 +424,7 @@ options_templates.update(options_section(('ui', "Live previews"), { })) options_templates.update(options_section(('sampler-params', "Sampler parameters"), { - "show_samplers": OptionInfo(["Euler a", "UniPC", "DDIM", "DPM++ SDE", "DPM++ SDE", "DPM2 Karras", "DPM++ 2M Karras"], "Show samplers in user interface", gr.CheckboxGroup, lambda: {"choices": [x.name for x in list_samplers()]}), + "show_samplers": OptionInfo(["Euler a", "UniPC", "DDIM", "DPM++ SDE", "DPM++ SDE", "DPM2 Karras", "DPM++ 2M Karras"], "Show samplers in user interface", gr.CheckboxGroup, lambda: {"choices": [x.name for x in list_samplers() if x.name != "PLMS"]}), "fallback_sampler": OptionInfo("Euler a", "Secondary sampler", gr.Dropdown, lambda: {"choices": ["None"] + [x.name for x in list_samplers()]}), "eta_ancestral": OptionInfo(1.0, "Noise multiplier for ancestral samplers (eta)", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}), "eta_ddim": OptionInfo(0.0, "Noise multiplier for DDIM (eta)", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}), From 2cd023ec7b68845fd63927a71267e3840b596d28 Mon Sep 17 00:00:00 2001 From: Alexandre Froger Date: Tue, 9 May 2023 21:20:08 +0800 Subject: [PATCH 3/5] Update ui.py [Issue]: UniPC always here #822 on load, select the first available sampler in UI ; this seems more expected than arbitrarily selecting UniPC which is the last one in the alphabetical list --- modules/ui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ui.py b/modules/ui.py index 77761269b..8502f9d9d 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -303,7 +303,7 @@ def create_output_panel(tabname, outdir): def create_sampler_and_steps_selection(choices, tabname): with FormRow(elem_id=f"sampler_selection_{tabname}"): - sampler_index = gr.Dropdown(label='Sampling method', elem_id=f"{tabname}_sampling", choices=[x.name for x in choices], value="UniPC" if tabname == 'txt2img' else "Euler a", type="index") + sampler_index = gr.Dropdown(label='Sampling method', elem_id=f"{tabname}_sampling", choices=[x.name for x in choices], value=choices[0].name if tabname == 'txt2img' else "Euler a", type="index") steps = gr.Slider(minimum=1, maximum=150, step=1, elem_id=f"{tabname}_steps", label="Sampling steps", value=20) return steps, sampler_index From e132f65c14845880883a976bc97682133e46c489 Mon Sep 17 00:00:00 2001 From: Alexandre Froger Date: Tue, 9 May 2023 22:23:14 +0800 Subject: [PATCH 4/5] Update sd_samplers.py [UX] UniPC and PLMS as fallback, PLMS forced, settings consistency #829 Refactor --- modules/sd_samplers.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/sd_samplers.py b/modules/sd_samplers.py index 8f74dbe7d..90c00bde4 100644 --- a/modules/sd_samplers.py +++ b/modules/sd_samplers.py @@ -34,11 +34,9 @@ def set_samplers(): shown_img2img = set(shared.opts.show_samplers) if len(shared.opts.show_samplers) == 0: - shown = set(['UniPC']) + shown = {'PLMS', 'UniPC'} else: - shown = set(shared.opts.show_samplers) - - shown.add('PLMS') + shown = set(shared.opts.show_samplers + ['PLMS']) samplers = [x for x in all_samplers if x.name in shown] samplers_for_img2img = [x for x in all_samplers if x.name in shown_img2img] From 304f47397084f9975b0a0c6bc47d580ae2828f05 Mon Sep 17 00:00:00 2001 From: Alexandre Froger Date: Tue, 9 May 2023 22:25:00 +0800 Subject: [PATCH 5/5] Update ui.py [UX] UniPC and PLMS as fallback, PLMS forced, settings consistency #829 Explicit app selected defaults: - If UniPC is not hidden, that should be default - Fallback to Euler a if not hidden - Fallback to first available --- modules/ui.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/ui.py b/modules/ui.py index 8502f9d9d..9d26faf87 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -303,7 +303,14 @@ def create_output_panel(tabname, outdir): def create_sampler_and_steps_selection(choices, tabname): with FormRow(elem_id=f"sampler_selection_{tabname}"): - sampler_index = gr.Dropdown(label='Sampling method', elem_id=f"{tabname}_sampling", choices=[x.name for x in choices], value=choices[0].name if tabname == 'txt2img' else "Euler a", type="index") + if 'UniPC' in [sampler.name for sampler in choices]: + chosen_sampler_name = 'UniPC' + elif 'Euler a' in [sampler.name for sampler in choices]: + chosen_sampler_name = 'Euler a' + else: + chosen_sampler_name = samplers[0].name + + sampler_index = gr.Dropdown(label='Sampling method', elem_id=f"{tabname}_sampling", choices=[x.name for x in choices], value=chosen_sampler_name if tabname == 'txt2img' else "Euler a", type="index") steps = gr.Slider(minimum=1, maximum=150, step=1, elem_id=f"{tabname}_steps", label="Sampling steps", value=20) return steps, sampler_index