aboutsummaryrefslogtreecommitdiff
path: root/modules/processing.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2022-09-18 20:44:57 +0300
committerAUTOMATIC <16777216c@gmail.com>2022-09-18 20:44:57 +0300
commit6a28aac8666a301b066f1a0717a2bd3924111595 (patch)
tree2d6223c6079343b7515c8e4670a6ae1fe99d056a /modules/processing.py
parentc76a616bc92df227f57289064e33dcf01ed258cd (diff)
prevent black screen when seed and variation seed are the same.
Diffstat (limited to 'modules/processing.py')
-rw-r--r--modules/processing.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/processing.py b/modules/processing.py
index 435e17eb..39029e8e 100644
--- a/modules/processing.py
+++ b/modules/processing.py
@@ -117,7 +117,12 @@ class Processed:
def slerp(val, low, high):
low_norm = low/torch.norm(low, dim=1, keepdim=True)
high_norm = high/torch.norm(high, dim=1, keepdim=True)
- omega = torch.acos((low_norm*high_norm).sum(1))
+ dot = (low_norm*high_norm).sum(1)
+
+ if dot.mean() > 0.9995:
+ return low * val + high * (1 - val)
+
+ omega = torch.acos(dot)
so = torch.sin(omega)
res = (torch.sin((1.0-val)*omega)/so).unsqueeze(1)*low + (torch.sin(val*omega)/so).unsqueeze(1) * high
return res