diff options
author | Bernard Maltais <bmaltais@gmail.com> | 2022-09-28 12:52:46 +0000 |
---|---|---|
committer | Bernard Maltais <bmaltais@gmail.com> | 2022-09-28 12:52:46 +0000 |
commit | fe2f0e172923d4714cfef137400841f9ff7541fc (patch) | |
tree | 92ada0a6afba9a31af9d052e7ec847a16809d727 /modules/extras.py | |
parent | c3bcc7e9fc0487ed4f7fe50a977e256346a4600a (diff) | |
download | stable-diffusion-webui-gfx803-fe2f0e172923d4714cfef137400841f9ff7541fc.tar.gz stable-diffusion-webui-gfx803-fe2f0e172923d4714cfef137400841f9ff7541fc.tar.bz2 stable-diffusion-webui-gfx803-fe2f0e172923d4714cfef137400841f9ff7541fc.zip |
Adding support for inverse sigmoid interpolation
Diffstat (limited to 'modules/extras.py')
-rw-r--r-- | modules/extras.py | 7 |
1 files changed, 7 insertions, 0 deletions
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]
|