aboutsummaryrefslogtreecommitdiffstats
path: root/extensions-builtin/Lora/lora.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2023-01-23 15:52:55 +0000
committerAUTOMATIC <16777216c@gmail.com>2023-01-23 15:52:55 +0000
commitc6f20f72629f3c417f10db2289d131441c6832f5 (patch)
treeec23325ff6fdcad6bef33ee3e64b1d0dfc461f69 /extensions-builtin/Lora/lora.py
parent171a5b3bb9eb06ebbd4a16c293fda5ce2a7fa462 (diff)
downloadstable-diffusion-webui-gfx803-c6f20f72629f3c417f10db2289d131441c6832f5.tar.gz
stable-diffusion-webui-gfx803-c6f20f72629f3c417f10db2289d131441c6832f5.tar.bz2
stable-diffusion-webui-gfx803-c6f20f72629f3c417f10db2289d131441c6832f5.zip
make loras before 0.4.0 ALSO work
Diffstat (limited to 'extensions-builtin/Lora/lora.py')
-rw-r--r--extensions-builtin/Lora/lora.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/extensions-builtin/Lora/lora.py b/extensions-builtin/Lora/lora.py
index 220e64ff..137e58f7 100644
--- a/extensions-builtin/Lora/lora.py
+++ b/extensions-builtin/Lora/lora.py
@@ -57,6 +57,7 @@ class LoraUpDownModule:
def __init__(self):
self.up = None
self.down = None
+ self.alpha = None
def assign_lora_names_to_compvis_modules(sd_model):
@@ -165,7 +166,7 @@ def lora_forward(module, input, res):
for lora in loaded_loras:
module = lora.modules.get(lora_layer_name, None)
if module is not None:
- res = res + module.up(module.down(input)) * lora.multiplier * module.alpha / module.up.weight.shape[1]
+ res = res + module.up(module.down(input)) * lora.multiplier * (module.alpha / module.up.weight.shape[1] if module.alpha else 1.0)
return res