MCPcopy Index your code
hub / github.com/huggingface/diffusers / delete_adapters

Method delete_adapters

src/diffusers/loaders/lora_base.py:839–875  ·  view source on GitHub ↗

Delete an adapter's LoRA layers from the pipeline. Args: adapter_names (`list[str, str]`): The names of the adapters to delete. Example: ```py from diffusers import AutoPipelineForText2Image import torch pipelin

(self, adapter_names: list[str] | str)

Source from the content-addressed store, hash-verified

837 enable_lora_for_text_encoder(model)
838
839 def delete_adapters(self, adapter_names: list[str] | str):
840 """
841 Delete an adapter's LoRA layers from the pipeline.
842
843 Args:
844 adapter_names (`list[str, str]`):
845 The names of the adapters to delete.
846
847 Example:
848
849 ```py
850 from diffusers import AutoPipelineForText2Image
851 import torch
852
853 pipeline = AutoPipelineForText2Image.from_pretrained(
854 "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16
855 ).to("cuda")
856 pipeline.load_lora_weights(
857 "jbilcke-hf/sdxl-cinematic-1", weight_name="pytorch_lora_weights.safetensors", adapter_names="cinematic"
858 )
859 pipeline.delete_adapters("cinematic")
860 ```
861 """
862 if not USE_PEFT_BACKEND:
863 raise ValueError("PEFT backend is required for this method.")
864
865 if isinstance(adapter_names, str):
866 adapter_names = [adapter_names]
867
868 for component in self._lora_loadable_modules:
869 model = getattr(self, component, None)
870 if model is not None:
871 if issubclass(model.__class__, ModelMixin):
872 model.delete_adapters(adapter_names)
873 elif issubclass(model.__class__, PreTrainedModel):
874 for adapter_name in adapter_names:
875 delete_adapter_layers(model, adapter_name)
876
877 def get_active_adapters(self) -> list[str]:
878 """

Callers

nothing calls this directly

Calls 1

delete_adapter_layersFunction · 0.85

Tested by

no test coverage detected