MCPcopy Create free account
hub / github.com/huggingface/diffusers / disable_lora

Method disable_lora

src/diffusers/loaders/lora_base.py:779–807  ·  view source on GitHub ↗

Disables the active LoRA layers of the pipeline. Example: ```py from diffusers import AutoPipelineForText2Image import torch pipeline = AutoPipelineForText2Image.from_pretrained( "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=t

(self)

Source from the content-addressed store, hash-verified

777 set_adapters_for_text_encoder(adapter_names, model, _component_adapter_weights[component])
778
779 def disable_lora(self):
780 """
781 Disables the active LoRA layers of the pipeline.
782
783 Example:
784
785 ```py
786 from diffusers import AutoPipelineForText2Image
787 import torch
788
789 pipeline = AutoPipelineForText2Image.from_pretrained(
790 "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16
791 ).to("cuda")
792 pipeline.load_lora_weights(
793 "jbilcke-hf/sdxl-cinematic-1", weight_name="pytorch_lora_weights.safetensors", adapter_name="cinematic"
794 )
795 pipeline.disable_lora()
796 ```
797 """
798 if not USE_PEFT_BACKEND:
799 raise ValueError("PEFT backend is required for this method.")
800
801 for component in self._lora_loadable_modules:
802 model = getattr(self, component, None)
803 if model is not None:
804 if issubclass(model.__class__, ModelMixin):
805 model.disable_lora()
806 elif issubclass(model.__class__, PreTrainedModel):
807 disable_lora_for_text_encoder(model)
808
809 def enable_lora(self):
810 """

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected