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

Method enable_lora

src/diffusers/loaders/lora_base.py:809–837  ·  view source on GitHub ↗

Enables 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=to

(self)

Source from the content-addressed store, hash-verified

807 disable_lora_for_text_encoder(model)
808
809 def enable_lora(self):
810 """
811 Enables the active LoRA layers of the pipeline.
812
813 Example:
814
815 ```py
816 from diffusers import AutoPipelineForText2Image
817 import torch
818
819 pipeline = AutoPipelineForText2Image.from_pretrained(
820 "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16
821 ).to("cuda")
822 pipeline.load_lora_weights(
823 "jbilcke-hf/sdxl-cinematic-1", weight_name="pytorch_lora_weights.safetensors", adapter_name="cinematic"
824 )
825 pipeline.enable_lora()
826 ```
827 """
828 if not USE_PEFT_BACKEND:
829 raise ValueError("PEFT backend is required for this method.")
830
831 for component in self._lora_loadable_modules:
832 model = getattr(self, component, None)
833 if model is not None:
834 if issubclass(model.__class__, ModelMixin):
835 model.enable_lora()
836 elif issubclass(model.__class__, PreTrainedModel):
837 enable_lora_for_text_encoder(model)
838
839 def delete_adapters(self, adapter_names: list[str] | str):
840 """

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected