Spaces:
Sleeping
Sleeping
Update app.py
Browse files157 unmodified lines158159160161162163164165166167168169157 unmodified lines# request asks for them. `load_lora_adapter` is the model-level loader (`PeftAdapterMixin`), used because# `MiniMaxH3ModularPipeline` has no pipeline-level `load_lora_weights` of its own.if LORA_REPO.lower() not in ("", "off", "none"):try:for name, filename in LORA_FILES.items():pipe.transformer.load_lora_adapter(LORA_REPO, weight_name=filename, adapter_name=name)pipe.transformer.set_adapters(list(LORA_FILES), weights=[0.0] * len(LORA_FILES))LORA_STATUS = "LoRAs loaded: " + ", ".join(f"`{name}` ({LORA_REPO}/{filename})" for name, filename in LORA_FILES.items())except Exception as error:LORA_STATUS = f"LoRA load failed: {type(error).__name__}: {error}"157 unmodified lines158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187157 unmodified lines# request asks for them. `load_lora_adapter` is the model-level loader (`PeftAdapterMixin`), used because# `MiniMaxH3ModularPipeline` has no pipeline-level `load_lora_weights` of its own.if LORA_REPO.lower() not in ("", "off", "none"):from peft.tuners.tuners_utils import BaseTunerLayertry:counts = {}for name, filename in LORA_FILES.items():pipe.transformer.load_lora_adapter(LORA_REPO, weight_name=filename, adapter_name=name, prefix=None)# `load_lora_adapter` warns-and-continues on a zero-key match instead of raising, so count# matched layers ourselves and fail loudly if a file attached nothing.counts[name] = sum(1for module in pipe.transformer.modules()if isinstance(module, BaseTunerLayer) and name in module.lora_A)if counts[name] == 0:raise RuntimeError(f"'{filename}' matched 0 target modules on MiniMaxH3Transformer3DModel — its LoRA "f"keys don't line up with this transformer's naming. Inspect its safetensors keys.")pipe.transformer.set_adapters(list(LORA_FILES), weights=[0.0] * len(LORA_FILES))LORA_STATUS = "LoRAs loaded: " + ", ".join(f"`{name}` ({LORA_REPO}/{filename}, {counts[name]} layers)"for name, filename in LORA_FILES.items())except Exception as error:LORA_STATUS = f"LoRA load failed: {type(error).__name__}: {error}"
app.py+20-2