Skip to content

Commit 07a18fd

Browse files
committed
fixed arg name
1 parent 9d09a56 commit 07a18fd

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/diffusers/loaders/ip_adapter.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -229,40 +229,40 @@ def load_ip_adapter(
229229
unet = getattr(self, self.unet_name) if not hasattr(self, "unet") else self.unet
230230
unet._load_ip_adapter_weights(state_dicts, low_cpu_mem_usage=low_cpu_mem_usage)
231231

232-
def set_ip_adapter_scale(self, scale_configs: Union[float, Dict, List[Union[float, Dict]]], default_scale=0.0):
232+
def set_ip_adapter_scale(self, scale: Union[float, Dict, List[Union[float, Dict]]], default_scale=0.0):
233233
"""
234-
Set IP-Adapter scales per-transformer block. Input `scale_configs` could be a single config or a list of
235-
configs for granular control over each IP-Adapter behavior. A config can be a float or a dictionary.
234+
Set IP-Adapter scales per-transformer block. Input `scale` could be a single config or a list of configs for
235+
granular control over each IP-Adapter behavior. A config can be a float or a dictionary.
236236
237237
Example:
238238
239239
```py
240240
# To use original IP-Adapter
241-
scale_configs = 1.0
242-
pipeline.set_ip_adapter_scale(scale_configs)
241+
scale = 1.0
242+
pipeline.set_ip_adapter_scale(scale)
243243
244244
# To use style block only
245-
scale_configs = {
245+
scale = {
246246
"up": {"block_0": [0.0, 1.0, 0.0]},
247247
}
248-
pipeline.set_ip_adapter_scale(scale_configs)
248+
pipeline.set_ip_adapter_scale(scale)
249249
250250
# To use style+layout blocks
251-
scale_configs = {
251+
scale = {
252252
"down": {"block_2": [0.0, 1.0]},
253253
"up": {"block_0": [0.0, 1.0, 0.0]},
254254
}
255-
pipeline.set_ip_adapter_scale(scale_configs)
255+
pipeline.set_ip_adapter_scale(scale)
256256
257257
# To use style and layout from 2 reference images
258-
scale_configs = [{"down": {"block_2": [0.0, 1.0]}}, {"up": {"block_0": [0.0, 1.0, 0.0]}}]
259-
pipeline.set_ip_adapter_scale(scale_configs)
258+
scales = [{"down": {"block_2": [0.0, 1.0]}}, {"up": {"block_0": [0.0, 1.0, 0.0]}}]
259+
pipeline.set_ip_adapter_scale(scales)
260260
```
261261
"""
262262
unet = getattr(self, self.unet_name) if not hasattr(self, "unet") else self.unet
263-
if not isinstance(scale_configs, list):
264-
scale_configs = [scale_configs]
265-
scale_configs = _maybe_expand_lora_scales(unet, scale_configs, default_scale=default_scale)
263+
if not isinstance(scale, list):
264+
scale = [scale]
265+
scale_configs = _maybe_expand_lora_scales(unet, scale, default_scale=default_scale)
266266

267267
for attn_name, attn_processor in unet.attn_processors.items():
268268
if isinstance(attn_processor, (IPAdapterAttnProcessor, IPAdapterAttnProcessor2_0)):
@@ -275,9 +275,9 @@ def set_ip_adapter_scale(self, scale_configs: Union[float, Dict, List[Union[floa
275275
scale_configs = scale_configs * len(attn_processor.scale)
276276
for i, scale_config in enumerate(scale_configs):
277277
if isinstance(scale_config, dict):
278-
for key, scale in scale_config.items():
279-
if attn_name.startswith(key):
280-
attn_processor.scale[i] = scale
278+
for k, s in scale_config.items():
279+
if attn_name.startswith(k):
280+
attn_processor.scale[i] = s
281281
else:
282282
attn_processor.scale[i] = scale_config
283283

0 commit comments

Comments
 (0)