From ca730fa3e608b61309cd9493b5b846454fe5aa63 Mon Sep 17 00:00:00 2001 From: QualiaRain <44004657+QualiaRain@users.noreply.github.com> Date: Sat, 13 Jun 2026 00:17:17 -0400 Subject: [PATCH] fix(lora-extract): stop overwriting the module selection list; fix dead no-LoRA guard make_lora reassigned the 'modules' selection arg to a named_modules() generator, so the subsequent 'te'/'unet' in modules checks tested an exhausted generator and silently skipped TE2 + UNet extraction. Also 'loaded_lora() == ""' never matched a loaded model (returns a list), so the no-LoRA-detected guard never fired. Co-Authored-By: Claude --- modules/lora/lora_extract.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/lora/lora_extract.py b/modules/lora/lora_extract.py index 1eb8a69bd..22c6019fc 100644 --- a/modules/lora/lora_extract.py +++ b/modules/lora/lora_extract.py @@ -122,7 +122,7 @@ def make_lora(fn, maxrank, auto_rank, rank_ratio, modules, overwrite): log.warning(msg) yield msg return - if loaded_lora() == "": + if not loaded_lora(): msg = "LoRA extract: no LoRA detected" log.warning(msg) yield msg @@ -141,8 +141,7 @@ def make_lora(fn, maxrank, auto_rank, rank_ratio, modules, overwrite): with rp.Progress(rp.TextColumn('[cyan]LoRA extract'), rp.BarColumn(), rp.TaskProgressColumn(), rp.TimeRemainingColumn(), rp.TimeElapsedColumn(), rp.TextColumn('[cyan]{task.description}'), console=console) as progress: if 'te' in modules and getattr(shared.sd_model, 'text_encoder', None) is not None: - modules = shared.sd_model.text_encoder.named_modules() - task = progress.add_task(description="te1 decompose", total=len(list(modules))) + task = progress.add_task(description="te1 decompose", total=len(list(shared.sd_model.text_encoder.named_modules()))) for name, module in shared.sd_model.text_encoder.named_modules(): progress.update(task, advance=1) weights_backup = getattr(module, "network_weights_backup", None) @@ -157,8 +156,7 @@ def make_lora(fn, maxrank, auto_rank, rank_ratio, modules, overwrite): t1 = time.time() if 'te' in modules and getattr(shared.sd_model, 'text_encoder_2', None) is not None: - modules = shared.sd_model.text_encoder_2.named_modules() - task = progress.add_task(description="te2 decompose", total=len(list(modules))) + task = progress.add_task(description="te2 decompose", total=len(list(shared.sd_model.text_encoder_2.named_modules()))) for name, module in shared.sd_model.text_encoder_2.named_modules(): progress.update(task, advance=1) weights_backup = getattr(module, "network_weights_backup", None) @@ -172,8 +170,7 @@ def make_lora(fn, maxrank, auto_rank, rank_ratio, modules, overwrite): t2 = time.time() if 'unet' in modules and getattr(shared.sd_model, 'unet', None) is not None: - modules = shared.sd_model.unet.named_modules() - task = progress.add_task(description="unet decompose", total=len(list(modules))) + task = progress.add_task(description="unet decompose", total=len(list(shared.sd_model.unet.named_modules()))) for name, module in shared.sd_model.unet.named_modules(): progress.update(task, advance=1) weights_backup = getattr(module, "network_weights_backup", None)