Skip to content

Commit 272c097

Browse files
committed
use lora.loaded_loras if available
* fix for webui 1.5.x
1 parent 136983e commit 272c097

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

scripts/gen_hashing.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44

55
import civitai.lib as civitai
6-
from modules import script_callbacks, sd_vae, shared
6+
from modules import script_callbacks, sd_vae, shared, hashes
77

88
additional_network_type_map = {
99
'lora': 'LORA',
@@ -62,6 +62,30 @@ def add_resource_hashes(params):
6262
short_hash = matching_resource[0]['hash'][:10]
6363
resource_hashes[f'{network_type}:{network_name}'] = short_hash
6464

65+
# check loaded_loras
66+
loaded = []
67+
try:
68+
import lora
69+
loaded = lora.loaded_lora
70+
except Exception:
71+
pass
72+
for item in loaded:
73+
name = item.name
74+
if f'lora:{name}' in resource_hashes.keys():
75+
continue
76+
77+
lora_on_disk = item.lora_on_disk if hasattr(item, "lora_on_disk") else item.network_on_disk if hasattr(item, "network_on_disk") else None
78+
if lora_on_disk is None:
79+
continue
80+
81+
hash = hashes.sha256(lora_on_disk.filename, "lora/" + lora_on_disk.name)
82+
if not hash:
83+
continue
84+
short_hash = hash[0:10]
85+
86+
name = name.replace(":", "").replace(",", "")
87+
resource_hashes[f'lora:{name}'] = short_hash
88+
6589
# Check for model hash in generation parameters
6690
model_match = re.search(model_hash_pattern, generation_params)
6791
if hashify_resources and model_match:

0 commit comments

Comments
 (0)