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

Function enable_lora_for_text_encoder

src/diffusers/loaders/lora_base.py:177–188  ·  view source on GitHub ↗

Enables the LoRA layers for the text encoder. Args: text_encoder (`torch.nn.Module`, *optional*): The text encoder module to enable the LoRA layers for. If `None`, it will try to get the `text_encoder` attribute.

(text_encoder: "PreTrainedModel" | None = None)

Source from the content-addressed store, hash-verified

175
176
177def enable_lora_for_text_encoder(text_encoder: "PreTrainedModel" | None = None):
178 """
179 Enables the LoRA layers for the text encoder.
180
181 Args:
182 text_encoder (`torch.nn.Module`, *optional*):
183 The text encoder module to enable the LoRA layers for. If `None`, it will try to get the `text_encoder`
184 attribute.
185 """
186 if text_encoder is None:
187 raise ValueError("Text Encoder not found.")
188 set_adapter_layers(text_encoder, enabled=True)
189
190
191def _remove_text_encoder_monkey_patch(text_encoder):

Callers 1

enable_loraMethod · 0.85

Calls 1

set_adapter_layersFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…