File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 33import os
44
55import civitai .lib as civitai
6- from modules import script_callbacks , sd_vae , shared
6+ from modules import script_callbacks , sd_vae , shared , hashes
77
88additional_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 :
You can’t perform that action at this time.
0 commit comments