From c3bcc7e9fc0487ed4f7fe50a977e256346a4600a Mon Sep 17 00:00:00 2001 From: Bernard Maltais Date: Wed, 28 Sep 2022 07:07:19 -0400 Subject: Switch active checkpoint selection to dropdown - Provides a better user experience - Better suited to variable list of options - Keep the UI "stable" as list contract or expand --- modules/shared.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/shared.py b/modules/shared.py index 2502fe2d..798a6f31 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -190,7 +190,7 @@ options_templates.update(options_section(('system', "System"), { })) options_templates.update(options_section(('sd', "Stable Diffusion"), { - "sd_model_checkpoint": OptionInfo(None, "Stable Diffusion checkpoint", gr.Radio, lambda: {"choices": [x.title for x in modules.sd_models.checkpoints_list.values()]}), + "sd_model_checkpoint": OptionInfo(None, "Stable Diffusion checkpoint", gr.Dropdown, lambda: {"choices": sorted([x.title for x in modules.sd_models.checkpoints_list.values()])}), "img2img_color_correction": OptionInfo(False, "Apply color correction to img2img results to match original colors."), "save_images_before_color_correction": OptionInfo(False, "Save a copy of image before applying color correction to img2img results"), "img2img_fix_steps": OptionInfo(False, "With img2img, do exactly the amount of steps the slider specifies (normally you'd do less with less denoising)."), -- cgit v1.2.1 From fe2f0e172923d4714cfef137400841f9ff7541fc Mon Sep 17 00:00:00 2001 From: Bernard Maltais Date: Wed, 28 Sep 2022 08:52:46 -0400 Subject: Adding support for inverse sigmoid interpolation --- modules/extras.py | 7 +++++++ modules/ui.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/extras.py b/modules/extras.py index b8ebc619..15de033a 100644 --- a/modules/extras.py +++ b/modules/extras.py @@ -150,6 +150,12 @@ def run_modelmerger(primary_model_name, secondary_model_name, interp_method, int alpha = alpha * alpha * (3 - (2 * alpha)) return theta0 + ((theta1 - theta0) * alpha) + # Inverse Smoothstep (https://en.wikipedia.org/wiki/Smoothstep) + def inv_sigmoid(theta0, theta1, alpha): + import math + alpha = 0.5 - math.sin(math.asin(1.0 - 2.0 * alpha) / 3.0) + return theta0 + ((theta1 - theta0) * alpha) + if os.path.exists(primary_model_name): primary_model_filename = primary_model_name primary_model_name = os.path.splitext(os.path.basename(primary_model_name))[0] @@ -174,6 +180,7 @@ def run_modelmerger(primary_model_name, secondary_model_name, interp_method, int theta_funcs = { "Weighted Sum": weighted_sum, "Sigmoid": sigmoid, + "Inverse Sigmoid": inv_sigmoid } theta_func = theta_funcs[interp_method] diff --git a/modules/ui.py b/modules/ui.py index 7db8edbd..f5d76613 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -864,7 +864,7 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger): primary_model_name = gr.Dropdown(ckpt_name_list, elem_id="modelmerger_primary_model_name", label="Primary Model Name") secondary_model_name = gr.Dropdown(ckpt_name_list, elem_id="modelmerger_secondary_model_name", label="Secondary Model Name") interp_amount = gr.Slider(minimum=0.0, maximum=1.0, step=0.05, label='Interpolation Amount', value=0.3) - interp_method = gr.Radio(choices=["Weighted Sum", "Sigmoid"], value="Weighted Sum", label="Interpolation Method") + interp_method = gr.Radio(choices=["Weighted Sum", "Sigmoid", "Inverse Sigmoid"], value="Weighted Sum", label="Interpolation Method") submit = gr.Button(elem_id="modelmerger_merge", label="Merge", variant='primary') with gr.Column(variant='panel'): -- cgit v1.2.1 From 228a2f30e7f8ae1a752c68ac189e9ca6bb4e29f6 Mon Sep 17 00:00:00 2001 From: Bernard Maltais Date: Wed, 28 Sep 2022 08:56:07 -0400 Subject: Remove unintended code commit for this PR --- modules/shared.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/shared.py b/modules/shared.py index 798a6f31..2502fe2d 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -190,7 +190,7 @@ options_templates.update(options_section(('system', "System"), { })) options_templates.update(options_section(('sd', "Stable Diffusion"), { - "sd_model_checkpoint": OptionInfo(None, "Stable Diffusion checkpoint", gr.Dropdown, lambda: {"choices": sorted([x.title for x in modules.sd_models.checkpoints_list.values()])}), + "sd_model_checkpoint": OptionInfo(None, "Stable Diffusion checkpoint", gr.Radio, lambda: {"choices": [x.title for x in modules.sd_models.checkpoints_list.values()]}), "img2img_color_correction": OptionInfo(False, "Apply color correction to img2img results to match original colors."), "save_images_before_color_correction": OptionInfo(False, "Save a copy of image before applying color correction to img2img results"), "img2img_fix_steps": OptionInfo(False, "With img2img, do exactly the amount of steps the slider specifies (normally you'd do less with less denoising)."), -- cgit v1.2.1