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

Method enable_lora

src/diffusers/loaders/peft.py:740–761  ·  view source on GitHub ↗

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

(self)

Source from the content-addressed store, hash-verified

738 set_adapter_layers(self, enabled=False)
739
740 def enable_lora(self):
741 """
742 Enables the active LoRA layers of the underlying model.
743
744 Example:
745
746 ```py
747 from diffusers import AutoPipelineForText2Image
748 import torch
749
750 pipeline = AutoPipelineForText2Image.from_pretrained(
751 "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16
752 ).to("cuda")
753 pipeline.load_lora_weights(
754 "jbilcke-hf/sdxl-cinematic-1", weight_name="pytorch_lora_weights.safetensors", adapter_name="cinematic"
755 )
756 pipeline.unet.enable_lora()
757 ```
758 """
759 if not USE_PEFT_BACKEND:
760 raise ValueError("PEFT backend is required for this method.")
761 set_adapter_layers(self, enabled=True)
762
763 def delete_adapters(self, adapter_names: list[str] | str):
764 """

Callers

nothing calls this directly

Calls 1

set_adapter_layersFunction · 0.85

Tested by

no test coverage detected