fix LoRA change detection on pipeline type change

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-06-29 12:52:37 -04:00
parent 1b4e1ff0ef
commit ff103bc849
4 changed files with 11 additions and 4 deletions
+6 -2
View File
@@ -141,10 +141,14 @@ class ExtraNetworkLora(extra_networks.ExtraNetwork):
def changed(self, requested: List[str], include: List[str], exclude: List[str]):
if shared.opts.lora_force_reload:
return True
sd_model = getattr(shared.sd_model, "pipe", shared.sd_model)
sd_model = shared.sd_model.pipe if hasattr(shared.sd_model, 'pipe') else shared.sd_model
if not hasattr(sd_model, 'loaded_loras'):
sd_model.loaded_loras = {}
key = f'{",".join(include)}:{",".join(exclude)}'
if include is None or len(include) == 0:
include = ['all']
if exclude is None or len(exclude) == 0:
exclude = ['none']
key = f'include={",".join(include)}:exclude={",".join(exclude)}'
loaded = sd_model.loaded_loras.get(key, [])
debug_log(f'Network load: type=LoRA key="{key}" requested={requested} loaded={loaded}')
if len(requested) != len(loaded):
+2
View File
@@ -858,6 +858,7 @@ def set_diffuser_pipe(pipe, new_pipe_type):
sd_checkpoint_info = getattr(pipe, "sd_checkpoint_info", None)
sd_model_checkpoint = getattr(pipe, "sd_model_checkpoint", None)
embedding_db = getattr(pipe, "embedding_db", None)
loaded_loras = getattr(pipe, "loaded_loras", None)
sd_model_hash = getattr(pipe, "sd_model_hash", None)
has_accelerate = getattr(pipe, "has_accelerate", None)
current_attn_name = getattr(pipe, "current_attn_name", None)
@@ -910,6 +911,7 @@ def set_diffuser_pipe(pipe, new_pipe_type):
new_pipe.has_accelerate = has_accelerate
new_pipe.current_attn_name = current_attn_name
new_pipe.default_scheduler = default_scheduler
new_pipe.loaded_loras = loaded_loras if loaded_loras is not None else {}
if image_encoder is not None:
new_pipe.image_encoder = image_encoder
if feature_extractor is not None: