@@ -61,6 +61,19 @@ def add_loras(
61
61
name: The name of the LoRA.
62
62
tensors: The `state_dict` of the LoRA to load.
63
63
scale: The scale to use for the LoRA.
64
+ unet_inclusions: A list of layer names, only layers with such a layer
65
+ in their ancestors will be considered when patching the UNet.
66
+ unet_exclusions: A list of layer names, layers with such a layer in
67
+ their ancestors will not be considered when patching the UNet.
68
+ If this is `None` then it defaults to `["TimestepEncoder"]`.
69
+ unet_preprocess: A map between parts of state dict keys and layer names.
70
+ This is used to attach some keys to specific parts of the UNet.
71
+ You should leave it set to `None` (it has a default value),
72
+ otherwise read the source code to understand how it works.
73
+ text_encoder_inclusions: A list of layer names, only layers with such a layer
74
+ in their ancestors will be considered when patching the text encoder.
75
+ text_encoder_exclusions: A list of layer names, layers with such a layer in
76
+ their ancestors will not be considered when patching the text encoder.
64
77
65
78
Raises:
66
79
AssertionError: If the Manager already has a LoRA with the same name.
@@ -117,15 +130,22 @@ def add_loras_to_text_encoder(
117
130
/ ,
118
131
include : list [str ] | None = None ,
119
132
exclude : list [str ] | None = None ,
133
+ debug_map : list [tuple [str , str ]] | None = None ,
120
134
) -> None :
121
- """Add multiple LoRAs to the text encoder.
135
+ """Add multiple LoRAs to the text encoder. See `add_loras` for details about arguments.
122
136
123
137
Args:
124
138
loras: The dictionary of LoRAs to add to the text encoder.
125
139
(keys are the names of the LoRAs, values are the LoRAs to add to the text encoder)
126
140
"""
127
141
text_encoder_loras = {key : loras [key ] for key in loras .keys () if "text" in key }
128
- auto_attach_loras (text_encoder_loras , self .clip_text_encoder , exclude = exclude , include = include )
142
+ auto_attach_loras (
143
+ text_encoder_loras ,
144
+ self .clip_text_encoder ,
145
+ exclude = exclude ,
146
+ include = include ,
147
+ debug_map = debug_map ,
148
+ )
129
149
130
150
def add_loras_to_unet (
131
151
self ,
@@ -136,7 +156,7 @@ def add_loras_to_unet(
136
156
preprocess : dict [str , str ] | None = None ,
137
157
debug_map : list [tuple [str , str ]] | None = None ,
138
158
) -> None :
139
- """Add multiple LoRAs to the U-Net.
159
+ """Add multiple LoRAs to the U-Net. See `add_loras` for details about arguments.
140
160
141
161
Args:
142
162
loras: The dictionary of LoRAs to add to the U-Net.
0 commit comments