mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-06-07 21:20:49 +00:00
Adding support for inverse sigmoid interpolation
This commit is contained in:
parent
c3bcc7e9fc
commit
fe2f0e1729
@ -150,6 +150,12 @@ def run_modelmerger(primary_model_name, secondary_model_name, interp_method, int
|
|||||||
alpha = alpha * alpha * (3 - (2 * alpha))
|
alpha = alpha * alpha * (3 - (2 * alpha))
|
||||||
return theta0 + ((theta1 - theta0) * 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):
|
if os.path.exists(primary_model_name):
|
||||||
primary_model_filename = primary_model_name
|
primary_model_filename = primary_model_name
|
||||||
primary_model_name = os.path.splitext(os.path.basename(primary_model_name))[0]
|
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 = {
|
theta_funcs = {
|
||||||
"Weighted Sum": weighted_sum,
|
"Weighted Sum": weighted_sum,
|
||||||
"Sigmoid": sigmoid,
|
"Sigmoid": sigmoid,
|
||||||
|
"Inverse Sigmoid": inv_sigmoid
|
||||||
}
|
}
|
||||||
theta_func = theta_funcs[interp_method]
|
theta_func = theta_funcs[interp_method]
|
||||||
|
|
||||||
|
@ -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")
|
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")
|
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_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')
|
submit = gr.Button(elem_id="modelmerger_merge", label="Merge", variant='primary')
|
||||||
|
|
||||||
with gr.Column(variant='panel'):
|
with gr.Column(variant='panel'):
|
||||||
|
Loading…
Reference in New Issue
Block a user