aboutsummaryrefslogtreecommitdiff
path: root/extensions-builtin/Lora/extra_networks_lora.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2023-05-19 22:59:29 +0300
committerAUTOMATIC <16777216c@gmail.com>2023-05-19 22:59:29 +0300
commit39ec4f06ffb2c26e1298b2c5d80874dc3fd693ac (patch)
tree7edd9b81f43b07826844e951241a4b4a15620257 /extensions-builtin/Lora/extra_networks_lora.py
parent87702febe08bddb9e8b952204c459927532ec6e6 (diff)
calculate hashes for Lora
add lora hashes to infotext when pasting infotext, use infotext's lora hashes to find local loras for <lora:xxx:1> entries whose hashes match loras the user has
Diffstat (limited to 'extensions-builtin/Lora/extra_networks_lora.py')
-rw-r--r--extensions-builtin/Lora/extra_networks_lora.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/extensions-builtin/Lora/extra_networks_lora.py b/extensions-builtin/Lora/extra_networks_lora.py
index ccb249ac..b5fea4d2 100644
--- a/extensions-builtin/Lora/extra_networks_lora.py
+++ b/extensions-builtin/Lora/extra_networks_lora.py
@@ -23,5 +23,23 @@ class ExtraNetworkLora(extra_networks.ExtraNetwork):
lora.load_loras(names, multipliers)
+ if shared.opts.lora_add_hashes_to_infotext:
+ lora_hashes = []
+ for item in lora.loaded_loras:
+ shorthash = item.lora_on_disk.shorthash
+ if not shorthash:
+ continue
+
+ alias = item.mentioned_name
+ if not alias:
+ continue
+
+ alias = alias.replace(":", "").replace(",", "")
+
+ lora_hashes.append(f"{alias}: {shorthash}")
+
+ if lora_hashes:
+ p.extra_generation_params["Lora hashes"] = ", ".join(lora_hashes)
+
def deactivate(self, p):
pass