Datasets:

ArXiv:
Diffusers Bot commited on
Commit
72dcdba
·
verified ·
1 Parent(s): 345d8a9

Upload folder using huggingface_hub

Browse files
main/fresco_v2v.py CHANGED
@@ -26,7 +26,7 @@ from gmflow.gmflow import GMFlow
26
  from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, CLIPVisionModelWithProjection
27
 
28
  from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
29
- from diffusers.loaders import StableDiffusionLoraLoaderMixin, TextualInversionLoaderMixin
30
  from diffusers.models import AutoencoderKL, ControlNetModel, ImageProjection, UNet2DConditionModel
31
  from diffusers.models.attention_processor import AttnProcessor2_0
32
  from diffusers.models.lora import adjust_lora_scale_text_encoder
@@ -1252,8 +1252,8 @@ class FrescoV2VPipeline(StableDiffusionControlNetImg2ImgPipeline):
1252
 
1253
  The pipeline also inherits the following loading methods:
1254
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
1255
- - [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`] for loading LoRA weights
1256
- - [`~loaders.StableDiffusionLoraLoaderMixin.save_lora_weights`] for saving LoRA weights
1257
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
1258
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
1259
 
@@ -1456,7 +1456,7 @@ class FrescoV2VPipeline(StableDiffusionControlNetImg2ImgPipeline):
1456
  """
1457
  # set lora scale so that monkey patched LoRA
1458
  # function of text encoder can correctly access it
1459
- if lora_scale is not None and isinstance(self, StableDiffusionLoraLoaderMixin):
1460
  self._lora_scale = lora_scale
1461
 
1462
  # dynamically adjust the LoRA scale
@@ -1588,7 +1588,7 @@ class FrescoV2VPipeline(StableDiffusionControlNetImg2ImgPipeline):
1588
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
1589
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
1590
 
1591
- if isinstance(self, StableDiffusionLoraLoaderMixin) and USE_PEFT_BACKEND:
1592
  # Retrieve the original scale by scaling back the LoRA layers
1593
  unscale_lora_layers(self.text_encoder, lora_scale)
1594
 
 
26
  from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, CLIPVisionModelWithProjection
27
 
28
  from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
29
+ from diffusers.loaders import LoraLoaderMixin, TextualInversionLoaderMixin
30
  from diffusers.models import AutoencoderKL, ControlNetModel, ImageProjection, UNet2DConditionModel
31
  from diffusers.models.attention_processor import AttnProcessor2_0
32
  from diffusers.models.lora import adjust_lora_scale_text_encoder
 
1252
 
1253
  The pipeline also inherits the following loading methods:
1254
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
1255
+ - [`~loaders.LoraLoaderMixin.load_lora_weights`] for loading LoRA weights
1256
+ - [`~loaders.LoraLoaderMixin.save_lora_weights`] for saving LoRA weights
1257
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
1258
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
1259
 
 
1456
  """
1457
  # set lora scale so that monkey patched LoRA
1458
  # function of text encoder can correctly access it
1459
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
1460
  self._lora_scale = lora_scale
1461
 
1462
  # dynamically adjust the LoRA scale
 
1588
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
1589
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
1590
 
1591
+ if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
1592
  # Retrieve the original scale by scaling back the LoRA layers
1593
  unscale_lora_layers(self.text_encoder, lora_scale)
1594
 
main/gluegen.py CHANGED
@@ -7,7 +7,7 @@ from transformers import AutoModel, AutoTokenizer, CLIPImageProcessor
7
 
8
  from diffusers import DiffusionPipeline
9
  from diffusers.image_processor import VaeImageProcessor
10
- from diffusers.loaders import StableDiffusionLoraLoaderMixin
11
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
12
  from diffusers.models.lora import adjust_lora_scale_text_encoder
13
  from diffusers.pipelines.pipeline_utils import StableDiffusionMixin
@@ -194,7 +194,7 @@ def retrieve_timesteps(
194
  return timesteps, num_inference_steps
195
 
196
 
197
- class GlueGenStableDiffusionPipeline(DiffusionPipeline, StableDiffusionMixin, StableDiffusionLoraLoaderMixin):
198
  def __init__(
199
  self,
200
  vae: AutoencoderKL,
@@ -290,7 +290,7 @@ class GlueGenStableDiffusionPipeline(DiffusionPipeline, StableDiffusionMixin, St
290
  """
291
  # set lora scale so that monkey patched LoRA
292
  # function of text encoder can correctly access it
293
- if lora_scale is not None and isinstance(self, StableDiffusionLoraLoaderMixin):
294
  self._lora_scale = lora_scale
295
 
296
  # dynamically adjust the LoRA scale
@@ -424,7 +424,7 @@ class GlueGenStableDiffusionPipeline(DiffusionPipeline, StableDiffusionMixin, St
424
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
425
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
426
 
427
- if isinstance(self, StableDiffusionLoraLoaderMixin) and USE_PEFT_BACKEND:
428
  # Retrieve the original scale by scaling back the LoRA layers
429
  unscale_lora_layers(self.text_encoder, lora_scale)
430
 
 
7
 
8
  from diffusers import DiffusionPipeline
9
  from diffusers.image_processor import VaeImageProcessor
10
+ from diffusers.loaders import LoraLoaderMixin
11
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
12
  from diffusers.models.lora import adjust_lora_scale_text_encoder
13
  from diffusers.pipelines.pipeline_utils import StableDiffusionMixin
 
194
  return timesteps, num_inference_steps
195
 
196
 
197
+ class GlueGenStableDiffusionPipeline(DiffusionPipeline, StableDiffusionMixin, LoraLoaderMixin):
198
  def __init__(
199
  self,
200
  vae: AutoencoderKL,
 
290
  """
291
  # set lora scale so that monkey patched LoRA
292
  # function of text encoder can correctly access it
293
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
294
  self._lora_scale = lora_scale
295
 
296
  # dynamically adjust the LoRA scale
 
424
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
425
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
426
 
427
+ if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
428
  # Retrieve the original scale by scaling back the LoRA layers
429
  unscale_lora_layers(self.text_encoder, lora_scale)
430
 
main/instaflow_one_step.py CHANGED
@@ -21,7 +21,7 @@ from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
21
 
22
  from diffusers.configuration_utils import FrozenDict
23
  from diffusers.image_processor import VaeImageProcessor
24
- from diffusers.loaders import FromSingleFileMixin, StableDiffusionLoraLoaderMixin, TextualInversionLoaderMixin
25
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
26
  from diffusers.models.lora import adjust_lora_scale_text_encoder
27
  from diffusers.pipelines.pipeline_utils import DiffusionPipeline, StableDiffusionMixin
@@ -53,11 +53,7 @@ def rescale_noise_cfg(noise_cfg, noise_pred_text, guidance_rescale=0.0):
53
 
54
 
55
  class InstaFlowPipeline(
56
- DiffusionPipeline,
57
- StableDiffusionMixin,
58
- TextualInversionLoaderMixin,
59
- StableDiffusionLoraLoaderMixin,
60
- FromSingleFileMixin,
61
  ):
62
  r"""
63
  Pipeline for text-to-image generation using Rectified Flow and Euler discretization.
@@ -68,8 +64,8 @@ class InstaFlowPipeline(
68
 
69
  The pipeline also inherits the following loading methods:
70
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
71
- - [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`] for loading LoRA weights
72
- - [`~loaders.StableDiffusionLoraLoaderMixin.save_lora_weights`] for saving LoRA weights
73
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
74
 
75
  Args:
@@ -255,7 +251,7 @@ class InstaFlowPipeline(
255
  """
256
  # set lora scale so that monkey patched LoRA
257
  # function of text encoder can correctly access it
258
- if lora_scale is not None and isinstance(self, StableDiffusionLoraLoaderMixin):
259
  self._lora_scale = lora_scale
260
 
261
  # dynamically adjust the LoRA scale
 
21
 
22
  from diffusers.configuration_utils import FrozenDict
23
  from diffusers.image_processor import VaeImageProcessor
24
+ from diffusers.loaders import FromSingleFileMixin, LoraLoaderMixin, TextualInversionLoaderMixin
25
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
26
  from diffusers.models.lora import adjust_lora_scale_text_encoder
27
  from diffusers.pipelines.pipeline_utils import DiffusionPipeline, StableDiffusionMixin
 
53
 
54
 
55
  class InstaFlowPipeline(
56
+ DiffusionPipeline, StableDiffusionMixin, TextualInversionLoaderMixin, LoraLoaderMixin, FromSingleFileMixin
 
 
 
 
57
  ):
58
  r"""
59
  Pipeline for text-to-image generation using Rectified Flow and Euler discretization.
 
64
 
65
  The pipeline also inherits the following loading methods:
66
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
67
+ - [`~loaders.LoraLoaderMixin.load_lora_weights`] for loading LoRA weights
68
+ - [`~loaders.LoraLoaderMixin.save_lora_weights`] for saving LoRA weights
69
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
70
 
71
  Args:
 
251
  """
252
  # set lora scale so that monkey patched LoRA
253
  # function of text encoder can correctly access it
254
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
255
  self._lora_scale = lora_scale
256
 
257
  # dynamically adjust the LoRA scale
main/ip_adapter_face_id.py CHANGED
@@ -24,12 +24,7 @@ from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, CLIPV
24
 
25
  from diffusers.configuration_utils import FrozenDict
26
  from diffusers.image_processor import VaeImageProcessor
27
- from diffusers.loaders import (
28
- FromSingleFileMixin,
29
- IPAdapterMixin,
30
- StableDiffusionLoraLoaderMixin,
31
- TextualInversionLoaderMixin,
32
- )
33
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
34
  from diffusers.models.attention_processor import (
35
  AttnProcessor,
@@ -135,7 +130,7 @@ class IPAdapterFaceIDStableDiffusionPipeline(
135
  DiffusionPipeline,
136
  StableDiffusionMixin,
137
  TextualInversionLoaderMixin,
138
- StableDiffusionLoraLoaderMixin,
139
  IPAdapterMixin,
140
  FromSingleFileMixin,
141
  ):
@@ -147,8 +142,8 @@ class IPAdapterFaceIDStableDiffusionPipeline(
147
 
148
  The pipeline also inherits the following loading methods:
149
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
150
- - [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`] for loading LoRA weights
151
- - [`~loaders.StableDiffusionLoraLoaderMixin.save_lora_weights`] for saving LoRA weights
152
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
153
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
154
 
@@ -523,7 +518,7 @@ class IPAdapterFaceIDStableDiffusionPipeline(
523
  """
524
  # set lora scale so that monkey patched LoRA
525
  # function of text encoder can correctly access it
526
- if lora_scale is not None and isinstance(self, StableDiffusionLoraLoaderMixin):
527
  self._lora_scale = lora_scale
528
 
529
  # dynamically adjust the LoRA scale
@@ -655,7 +650,7 @@ class IPAdapterFaceIDStableDiffusionPipeline(
655
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
656
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
657
 
658
- if isinstance(self, StableDiffusionLoraLoaderMixin) and USE_PEFT_BACKEND:
659
  # Retrieve the original scale by scaling back the LoRA layers
660
  unscale_lora_layers(self.text_encoder, lora_scale)
661
 
 
24
 
25
  from diffusers.configuration_utils import FrozenDict
26
  from diffusers.image_processor import VaeImageProcessor
27
+ from diffusers.loaders import FromSingleFileMixin, IPAdapterMixin, LoraLoaderMixin, TextualInversionLoaderMixin
 
 
 
 
 
28
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
29
  from diffusers.models.attention_processor import (
30
  AttnProcessor,
 
130
  DiffusionPipeline,
131
  StableDiffusionMixin,
132
  TextualInversionLoaderMixin,
133
+ LoraLoaderMixin,
134
  IPAdapterMixin,
135
  FromSingleFileMixin,
136
  ):
 
142
 
143
  The pipeline also inherits the following loading methods:
144
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
145
+ - [`~loaders.LoraLoaderMixin.load_lora_weights`] for loading LoRA weights
146
+ - [`~loaders.LoraLoaderMixin.save_lora_weights`] for saving LoRA weights
147
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
148
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
149
 
 
518
  """
519
  # set lora scale so that monkey patched LoRA
520
  # function of text encoder can correctly access it
521
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
522
  self._lora_scale = lora_scale
523
 
524
  # dynamically adjust the LoRA scale
 
650
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
651
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
652
 
653
+ if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
654
  # Retrieve the original scale by scaling back the LoRA layers
655
  unscale_lora_layers(self.text_encoder, lora_scale)
656
 
main/kohya_hires_fix.py CHANGED
@@ -395,8 +395,8 @@ class StableDiffusionHighResFixPipeline(StableDiffusionPipeline):
395
 
396
  The pipeline also inherits the following loading methods:
397
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
398
- - [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`] for loading LoRA weights
399
- - [`~loaders.StableDiffusionLoraLoaderMixin.save_lora_weights`] for saving LoRA weights
400
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
401
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
402
 
 
395
 
396
  The pipeline also inherits the following loading methods:
397
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
398
+ - [`~loaders.LoraLoaderMixin.load_lora_weights`] for loading LoRA weights
399
+ - [`~loaders.LoraLoaderMixin.save_lora_weights`] for saving LoRA weights
400
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
401
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
402
 
main/latent_consistency_interpolate.py CHANGED
@@ -6,7 +6,7 @@ import torch
6
  from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
7
 
8
  from diffusers.image_processor import VaeImageProcessor
9
- from diffusers.loaders import FromSingleFileMixin, StableDiffusionLoraLoaderMixin, TextualInversionLoaderMixin
10
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
11
  from diffusers.models.lora import adjust_lora_scale_text_encoder
12
  from diffusers.pipelines.pipeline_utils import DiffusionPipeline, StableDiffusionMixin
@@ -190,11 +190,7 @@ def slerp(
190
 
191
 
192
  class LatentConsistencyModelWalkPipeline(
193
- DiffusionPipeline,
194
- StableDiffusionMixin,
195
- TextualInversionLoaderMixin,
196
- StableDiffusionLoraLoaderMixin,
197
- FromSingleFileMixin,
198
  ):
199
  r"""
200
  Pipeline for text-to-image generation using a latent consistency model.
@@ -204,8 +200,8 @@ class LatentConsistencyModelWalkPipeline(
204
 
205
  The pipeline also inherits the following loading methods:
206
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
207
- - [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`] for loading LoRA weights
208
- - [`~loaders.StableDiffusionLoraLoaderMixin.save_lora_weights`] for saving LoRA weights
209
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
210
 
211
  Args:
@@ -321,7 +317,7 @@ class LatentConsistencyModelWalkPipeline(
321
  """
322
  # set lora scale so that monkey patched LoRA
323
  # function of text encoder can correctly access it
324
- if lora_scale is not None and isinstance(self, StableDiffusionLoraLoaderMixin):
325
  self._lora_scale = lora_scale
326
 
327
  # dynamically adjust the LoRA scale
@@ -453,7 +449,7 @@ class LatentConsistencyModelWalkPipeline(
453
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
454
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
455
 
456
- if isinstance(self, StableDiffusionLoraLoaderMixin) and USE_PEFT_BACKEND:
457
  # Retrieve the original scale by scaling back the LoRA layers
458
  unscale_lora_layers(self.text_encoder, lora_scale)
459
 
 
6
  from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
7
 
8
  from diffusers.image_processor import VaeImageProcessor
9
+ from diffusers.loaders import FromSingleFileMixin, LoraLoaderMixin, TextualInversionLoaderMixin
10
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
11
  from diffusers.models.lora import adjust_lora_scale_text_encoder
12
  from diffusers.pipelines.pipeline_utils import DiffusionPipeline, StableDiffusionMixin
 
190
 
191
 
192
  class LatentConsistencyModelWalkPipeline(
193
+ DiffusionPipeline, StableDiffusionMixin, TextualInversionLoaderMixin, LoraLoaderMixin, FromSingleFileMixin
 
 
 
 
194
  ):
195
  r"""
196
  Pipeline for text-to-image generation using a latent consistency model.
 
200
 
201
  The pipeline also inherits the following loading methods:
202
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
203
+ - [`~loaders.LoraLoaderMixin.load_lora_weights`] for loading LoRA weights
204
+ - [`~loaders.LoraLoaderMixin.save_lora_weights`] for saving LoRA weights
205
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
206
 
207
  Args:
 
317
  """
318
  # set lora scale so that monkey patched LoRA
319
  # function of text encoder can correctly access it
320
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
321
  self._lora_scale = lora_scale
322
 
323
  # dynamically adjust the LoRA scale
 
449
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
450
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
451
 
452
+ if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
453
  # Retrieve the original scale by scaling back the LoRA layers
454
  unscale_lora_layers(self.text_encoder, lora_scale)
455
 
main/llm_grounded_diffusion.py CHANGED
@@ -29,12 +29,7 @@ from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, CLIPV
29
 
30
  from diffusers.configuration_utils import FrozenDict
31
  from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
32
- from diffusers.loaders import (
33
- FromSingleFileMixin,
34
- IPAdapterMixin,
35
- StableDiffusionLoraLoaderMixin,
36
- TextualInversionLoaderMixin,
37
- )
38
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
39
  from diffusers.models.attention import Attention, GatedSelfAttentionDense
40
  from diffusers.models.attention_processor import AttnProcessor2_0
@@ -276,7 +271,7 @@ class LLMGroundedDiffusionPipeline(
276
  DiffusionPipeline,
277
  StableDiffusionMixin,
278
  TextualInversionLoaderMixin,
279
- StableDiffusionLoraLoaderMixin,
280
  IPAdapterMixin,
281
  FromSingleFileMixin,
282
  ):
@@ -1268,7 +1263,7 @@ class LLMGroundedDiffusionPipeline(
1268
  """
1269
  # set lora scale so that monkey patched LoRA
1270
  # function of text encoder can correctly access it
1271
- if lora_scale is not None and isinstance(self, StableDiffusionLoraLoaderMixin):
1272
  self._lora_scale = lora_scale
1273
 
1274
  # dynamically adjust the LoRA scale
@@ -1402,7 +1397,7 @@ class LLMGroundedDiffusionPipeline(
1402
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
1403
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
1404
 
1405
- if isinstance(self, StableDiffusionLoraLoaderMixin) and USE_PEFT_BACKEND:
1406
  # Retrieve the original scale by scaling back the LoRA layers
1407
  unscale_lora_layers(self.text_encoder, lora_scale)
1408
 
 
29
 
30
  from diffusers.configuration_utils import FrozenDict
31
  from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
32
+ from diffusers.loaders import FromSingleFileMixin, IPAdapterMixin, LoraLoaderMixin, TextualInversionLoaderMixin
 
 
 
 
 
33
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
34
  from diffusers.models.attention import Attention, GatedSelfAttentionDense
35
  from diffusers.models.attention_processor import AttnProcessor2_0
 
271
  DiffusionPipeline,
272
  StableDiffusionMixin,
273
  TextualInversionLoaderMixin,
274
+ LoraLoaderMixin,
275
  IPAdapterMixin,
276
  FromSingleFileMixin,
277
  ):
 
1263
  """
1264
  # set lora scale so that monkey patched LoRA
1265
  # function of text encoder can correctly access it
1266
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
1267
  self._lora_scale = lora_scale
1268
 
1269
  # dynamically adjust the LoRA scale
 
1397
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
1398
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
1399
 
1400
+ if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
1401
  # Retrieve the original scale by scaling back the LoRA layers
1402
  unscale_lora_layers(self.text_encoder, lora_scale)
1403
 
main/lpw_stable_diffusion.py CHANGED
@@ -11,7 +11,7 @@ from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
11
  from diffusers import DiffusionPipeline
12
  from diffusers.configuration_utils import FrozenDict
13
  from diffusers.image_processor import VaeImageProcessor
14
- from diffusers.loaders import FromSingleFileMixin, StableDiffusionLoraLoaderMixin, TextualInversionLoaderMixin
15
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
16
  from diffusers.pipelines.pipeline_utils import StableDiffusionMixin
17
  from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput, StableDiffusionSafetyChecker
@@ -409,11 +409,7 @@ def preprocess_mask(mask, batch_size, scale_factor=8):
409
 
410
 
411
  class StableDiffusionLongPromptWeightingPipeline(
412
- DiffusionPipeline,
413
- StableDiffusionMixin,
414
- TextualInversionLoaderMixin,
415
- StableDiffusionLoraLoaderMixin,
416
- FromSingleFileMixin,
417
  ):
418
  r"""
419
  Pipeline for text-to-image generation using Stable Diffusion without tokens length limit, and support parsing
 
11
  from diffusers import DiffusionPipeline
12
  from diffusers.configuration_utils import FrozenDict
13
  from diffusers.image_processor import VaeImageProcessor
14
+ from diffusers.loaders import FromSingleFileMixin, LoraLoaderMixin, TextualInversionLoaderMixin
15
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
16
  from diffusers.pipelines.pipeline_utils import StableDiffusionMixin
17
  from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput, StableDiffusionSafetyChecker
 
409
 
410
 
411
  class StableDiffusionLongPromptWeightingPipeline(
412
+ DiffusionPipeline, StableDiffusionMixin, TextualInversionLoaderMixin, LoraLoaderMixin, FromSingleFileMixin
 
 
 
 
413
  ):
414
  r"""
415
  Pipeline for text-to-image generation using Stable Diffusion without tokens length limit, and support parsing
main/lpw_stable_diffusion_xl.py CHANGED
@@ -22,12 +22,7 @@ from transformers import (
22
 
23
  from diffusers import DiffusionPipeline, StableDiffusionXLPipeline
24
  from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
25
- from diffusers.loaders import (
26
- FromSingleFileMixin,
27
- IPAdapterMixin,
28
- StableDiffusionLoraLoaderMixin,
29
- TextualInversionLoaderMixin,
30
- )
31
  from diffusers.models import AutoencoderKL, ImageProjection, UNet2DConditionModel
32
  from diffusers.models.attention_processor import AttnProcessor2_0, XFormersAttnProcessor
33
  from diffusers.pipelines.pipeline_utils import StableDiffusionMixin
@@ -549,7 +544,7 @@ class SDXLLongPromptWeightingPipeline(
549
  StableDiffusionMixin,
550
  FromSingleFileMixin,
551
  IPAdapterMixin,
552
- StableDiffusionLoraLoaderMixin,
553
  TextualInversionLoaderMixin,
554
  ):
555
  r"""
@@ -561,8 +556,8 @@ class SDXLLongPromptWeightingPipeline(
561
  The pipeline also inherits the following loading methods:
562
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
563
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
564
- - [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`] for loading LoRA weights
565
- - [`~loaders.StableDiffusionLoraLoaderMixin.save_lora_weights`] for saving LoRA weights
566
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
567
 
568
  Args:
@@ -743,7 +738,7 @@ class SDXLLongPromptWeightingPipeline(
743
 
744
  # set lora scale so that monkey patched LoRA
745
  # function of text encoder can correctly access it
746
- if lora_scale is not None and isinstance(self, StableDiffusionLoraLoaderMixin):
747
  self._lora_scale = lora_scale
748
 
749
  if prompt is not None and isinstance(prompt, str):
 
22
 
23
  from diffusers import DiffusionPipeline, StableDiffusionXLPipeline
24
  from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
25
+ from diffusers.loaders import FromSingleFileMixin, IPAdapterMixin, LoraLoaderMixin, TextualInversionLoaderMixin
 
 
 
 
 
26
  from diffusers.models import AutoencoderKL, ImageProjection, UNet2DConditionModel
27
  from diffusers.models.attention_processor import AttnProcessor2_0, XFormersAttnProcessor
28
  from diffusers.pipelines.pipeline_utils import StableDiffusionMixin
 
544
  StableDiffusionMixin,
545
  FromSingleFileMixin,
546
  IPAdapterMixin,
547
+ LoraLoaderMixin,
548
  TextualInversionLoaderMixin,
549
  ):
550
  r"""
 
556
  The pipeline also inherits the following loading methods:
557
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
558
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
559
+ - [`~loaders.LoraLoaderMixin.load_lora_weights`] for loading LoRA weights
560
+ - [`~loaders.LoraLoaderMixin.save_lora_weights`] for saving LoRA weights
561
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
562
 
563
  Args:
 
738
 
739
  # set lora scale so that monkey patched LoRA
740
  # function of text encoder can correctly access it
741
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
742
  self._lora_scale = lora_scale
743
 
744
  if prompt is not None and isinstance(prompt, str):
main/pipeline_animatediff_controlnet.py CHANGED
@@ -22,7 +22,7 @@ from PIL import Image
22
  from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, CLIPVisionModelWithProjection
23
 
24
  from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
25
- from diffusers.loaders import IPAdapterMixin, StableDiffusionLoraLoaderMixin, TextualInversionLoaderMixin
26
  from diffusers.models import AutoencoderKL, ControlNetModel, ImageProjection, UNet2DConditionModel, UNetMotionModel
27
  from diffusers.models.lora import adjust_lora_scale_text_encoder
28
  from diffusers.models.unets.unet_motion_model import MotionAdapter
@@ -114,11 +114,7 @@ def tensor2vid(video: torch.Tensor, processor, output_type="np"):
114
 
115
 
116
  class AnimateDiffControlNetPipeline(
117
- DiffusionPipeline,
118
- StableDiffusionMixin,
119
- TextualInversionLoaderMixin,
120
- IPAdapterMixin,
121
- StableDiffusionLoraLoaderMixin,
122
  ):
123
  r"""
124
  Pipeline for text-to-video generation.
@@ -128,8 +124,8 @@ class AnimateDiffControlNetPipeline(
128
 
129
  The pipeline also inherits the following loading methods:
130
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
131
- - [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`] for loading LoRA weights
132
- - [`~loaders.StableDiffusionLoraLoaderMixin.save_lora_weights`] for saving LoRA weights
133
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
134
 
135
  Args:
@@ -238,7 +234,7 @@ class AnimateDiffControlNetPipeline(
238
  """
239
  # set lora scale so that monkey patched LoRA
240
  # function of text encoder can correctly access it
241
- if lora_scale is not None and isinstance(self, StableDiffusionLoraLoaderMixin):
242
  self._lora_scale = lora_scale
243
 
244
  # dynamically adjust the LoRA scale
@@ -370,7 +366,7 @@ class AnimateDiffControlNetPipeline(
370
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
371
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
372
 
373
- if isinstance(self, StableDiffusionLoraLoaderMixin) and USE_PEFT_BACKEND:
374
  # Retrieve the original scale by scaling back the LoRA layers
375
  unscale_lora_layers(self.text_encoder, lora_scale)
376
 
 
22
  from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, CLIPVisionModelWithProjection
23
 
24
  from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
25
+ from diffusers.loaders import IPAdapterMixin, LoraLoaderMixin, TextualInversionLoaderMixin
26
  from diffusers.models import AutoencoderKL, ControlNetModel, ImageProjection, UNet2DConditionModel, UNetMotionModel
27
  from diffusers.models.lora import adjust_lora_scale_text_encoder
28
  from diffusers.models.unets.unet_motion_model import MotionAdapter
 
114
 
115
 
116
  class AnimateDiffControlNetPipeline(
117
+ DiffusionPipeline, StableDiffusionMixin, TextualInversionLoaderMixin, IPAdapterMixin, LoraLoaderMixin
 
 
 
 
118
  ):
119
  r"""
120
  Pipeline for text-to-video generation.
 
124
 
125
  The pipeline also inherits the following loading methods:
126
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
127
+ - [`~loaders.LoraLoaderMixin.load_lora_weights`] for loading LoRA weights
128
+ - [`~loaders.LoraLoaderMixin.save_lora_weights`] for saving LoRA weights
129
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
130
 
131
  Args:
 
234
  """
235
  # set lora scale so that monkey patched LoRA
236
  # function of text encoder can correctly access it
237
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
238
  self._lora_scale = lora_scale
239
 
240
  # dynamically adjust the LoRA scale
 
366
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
367
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
368
 
369
+ if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
370
  # Retrieve the original scale by scaling back the LoRA layers
371
  unscale_lora_layers(self.text_encoder, lora_scale)
372
 
main/pipeline_animatediff_img2video.py CHANGED
@@ -27,7 +27,7 @@ import torch
27
  from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, CLIPVisionModelWithProjection
28
 
29
  from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
30
- from diffusers.loaders import IPAdapterMixin, StableDiffusionLoraLoaderMixin, TextualInversionLoaderMixin
31
  from diffusers.models import AutoencoderKL, ImageProjection, UNet2DConditionModel, UNetMotionModel
32
  from diffusers.models.lora import adjust_lora_scale_text_encoder
33
  from diffusers.models.unet_motion_model import MotionAdapter
@@ -240,11 +240,7 @@ def retrieve_timesteps(
240
 
241
 
242
  class AnimateDiffImgToVideoPipeline(
243
- DiffusionPipeline,
244
- StableDiffusionMixin,
245
- TextualInversionLoaderMixin,
246
- IPAdapterMixin,
247
- StableDiffusionLoraLoaderMixin,
248
  ):
249
  r"""
250
  Pipeline for image-to-video generation.
@@ -254,8 +250,8 @@ class AnimateDiffImgToVideoPipeline(
254
 
255
  The pipeline also inherits the following loading methods:
256
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
257
- - [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`] for loading LoRA weights
258
- - [`~loaders.StableDiffusionLoraLoaderMixin.save_lora_weights`] for saving LoRA weights
259
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
260
 
261
  Args:
@@ -355,7 +351,7 @@ class AnimateDiffImgToVideoPipeline(
355
  """
356
  # set lora scale so that monkey patched LoRA
357
  # function of text encoder can correctly access it
358
- if lora_scale is not None and isinstance(self, StableDiffusionLoraLoaderMixin):
359
  self._lora_scale = lora_scale
360
 
361
  # dynamically adjust the LoRA scale
@@ -487,7 +483,7 @@ class AnimateDiffImgToVideoPipeline(
487
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
488
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
489
 
490
- if isinstance(self, StableDiffusionLoraLoaderMixin) and USE_PEFT_BACKEND:
491
  # Retrieve the original scale by scaling back the LoRA layers
492
  unscale_lora_layers(self.text_encoder, lora_scale)
493
 
 
27
  from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, CLIPVisionModelWithProjection
28
 
29
  from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
30
+ from diffusers.loaders import IPAdapterMixin, LoraLoaderMixin, TextualInversionLoaderMixin
31
  from diffusers.models import AutoencoderKL, ImageProjection, UNet2DConditionModel, UNetMotionModel
32
  from diffusers.models.lora import adjust_lora_scale_text_encoder
33
  from diffusers.models.unet_motion_model import MotionAdapter
 
240
 
241
 
242
  class AnimateDiffImgToVideoPipeline(
243
+ DiffusionPipeline, StableDiffusionMixin, TextualInversionLoaderMixin, IPAdapterMixin, LoraLoaderMixin
 
 
 
 
244
  ):
245
  r"""
246
  Pipeline for image-to-video generation.
 
250
 
251
  The pipeline also inherits the following loading methods:
252
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
253
+ - [`~loaders.LoraLoaderMixin.load_lora_weights`] for loading LoRA weights
254
+ - [`~loaders.LoraLoaderMixin.save_lora_weights`] for saving LoRA weights
255
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
256
 
257
  Args:
 
351
  """
352
  # set lora scale so that monkey patched LoRA
353
  # function of text encoder can correctly access it
354
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
355
  self._lora_scale = lora_scale
356
 
357
  # dynamically adjust the LoRA scale
 
483
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
484
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
485
 
486
+ if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
487
  # Retrieve the original scale by scaling back the LoRA layers
488
  unscale_lora_layers(self.text_encoder, lora_scale)
489
 
main/pipeline_demofusion_sdxl.py CHANGED
@@ -12,7 +12,7 @@ from transformers import CLIPTextModel, CLIPTextModelWithProjection, CLIPTokeniz
12
  from diffusers.image_processor import VaeImageProcessor
13
  from diffusers.loaders import (
14
  FromSingleFileMixin,
15
- StableDiffusionLoraLoaderMixin,
16
  TextualInversionLoaderMixin,
17
  )
18
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
@@ -89,11 +89,7 @@ def rescale_noise_cfg(noise_cfg, noise_pred_text, guidance_rescale=0.0):
89
 
90
 
91
  class DemoFusionSDXLPipeline(
92
- DiffusionPipeline,
93
- StableDiffusionMixin,
94
- FromSingleFileMixin,
95
- StableDiffusionLoraLoaderMixin,
96
- TextualInversionLoaderMixin,
97
  ):
98
  r"""
99
  Pipeline for text-to-image generation using Stable Diffusion XL.
@@ -235,7 +231,7 @@ class DemoFusionSDXLPipeline(
235
 
236
  # set lora scale so that monkey patched LoRA
237
  # function of text encoder can correctly access it
238
- if lora_scale is not None and isinstance(self, StableDiffusionLoraLoaderMixin):
239
  self._lora_scale = lora_scale
240
 
241
  # dynamically adjust the LoRA scale
 
12
  from diffusers.image_processor import VaeImageProcessor
13
  from diffusers.loaders import (
14
  FromSingleFileMixin,
15
+ LoraLoaderMixin,
16
  TextualInversionLoaderMixin,
17
  )
18
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
 
89
 
90
 
91
  class DemoFusionSDXLPipeline(
92
+ DiffusionPipeline, StableDiffusionMixin, FromSingleFileMixin, LoraLoaderMixin, TextualInversionLoaderMixin
 
 
 
 
93
  ):
94
  r"""
95
  Pipeline for text-to-image generation using Stable Diffusion XL.
 
231
 
232
  # set lora scale so that monkey patched LoRA
233
  # function of text encoder can correctly access it
234
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
235
  self._lora_scale = lora_scale
236
 
237
  # dynamically adjust the LoRA scale
main/pipeline_fabric.py CHANGED
@@ -21,7 +21,7 @@ from transformers import CLIPTextModel, CLIPTokenizer
21
  from diffusers import AutoencoderKL, UNet2DConditionModel
22
  from diffusers.configuration_utils import FrozenDict
23
  from diffusers.image_processor import VaeImageProcessor
24
- from diffusers.loaders import StableDiffusionLoraLoaderMixin, TextualInversionLoaderMixin
25
  from diffusers.models.attention import BasicTransformerBlock
26
  from diffusers.models.attention_processor import LoRAAttnProcessor
27
  from diffusers.pipelines.pipeline_utils import DiffusionPipeline
@@ -222,7 +222,7 @@ class FabricPipeline(DiffusionPipeline):
222
  """
223
  # set lora scale so that monkey patched LoRA
224
  # function of text encoder can correctly access it
225
- if lora_scale is not None and isinstance(self, StableDiffusionLoraLoaderMixin):
226
  self._lora_scale = lora_scale
227
 
228
  if prompt is not None and isinstance(prompt, str):
 
21
  from diffusers import AutoencoderKL, UNet2DConditionModel
22
  from diffusers.configuration_utils import FrozenDict
23
  from diffusers.image_processor import VaeImageProcessor
24
+ from diffusers.loaders import LoraLoaderMixin, TextualInversionLoaderMixin
25
  from diffusers.models.attention import BasicTransformerBlock
26
  from diffusers.models.attention_processor import LoRAAttnProcessor
27
  from diffusers.pipelines.pipeline_utils import DiffusionPipeline
 
222
  """
223
  # set lora scale so that monkey patched LoRA
224
  # function of text encoder can correctly access it
225
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
226
  self._lora_scale = lora_scale
227
 
228
  if prompt is not None and isinstance(prompt, str):
main/pipeline_prompt2prompt.py CHANGED
@@ -35,7 +35,7 @@ from diffusers.image_processor import VaeImageProcessor
35
  from diffusers.loaders import (
36
  FromSingleFileMixin,
37
  IPAdapterMixin,
38
- StableDiffusionLoraLoaderMixin,
39
  TextualInversionLoaderMixin,
40
  )
41
  from diffusers.models.attention import Attention
@@ -75,7 +75,7 @@ def rescale_noise_cfg(noise_cfg, noise_pred_text, guidance_rescale=0.0):
75
  class Prompt2PromptPipeline(
76
  DiffusionPipeline,
77
  TextualInversionLoaderMixin,
78
- StableDiffusionLoraLoaderMixin,
79
  IPAdapterMixin,
80
  FromSingleFileMixin,
81
  ):
@@ -87,8 +87,8 @@ class Prompt2PromptPipeline(
87
 
88
  The pipeline also inherits the following loading methods:
89
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
90
- - [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`] for loading LoRA weights
91
- - [`~loaders.StableDiffusionLoraLoaderMixin.save_lora_weights`] for saving LoRA weights
92
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
93
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
94
 
@@ -286,7 +286,7 @@ class Prompt2PromptPipeline(
286
  """
287
  # set lora scale so that monkey patched LoRA
288
  # function of text encoder can correctly access it
289
- if lora_scale is not None and isinstance(self, StableDiffusionLoraLoaderMixin):
290
  self._lora_scale = lora_scale
291
 
292
  # dynamically adjust the LoRA scale
@@ -420,7 +420,7 @@ class Prompt2PromptPipeline(
420
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
421
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
422
 
423
- if isinstance(self, StableDiffusionLoraLoaderMixin) and USE_PEFT_BACKEND:
424
  # Retrieve the original scale by scaling back the LoRA layers
425
  unscale_lora_layers(self.text_encoder, lora_scale)
426
 
 
35
  from diffusers.loaders import (
36
  FromSingleFileMixin,
37
  IPAdapterMixin,
38
+ LoraLoaderMixin,
39
  TextualInversionLoaderMixin,
40
  )
41
  from diffusers.models.attention import Attention
 
75
  class Prompt2PromptPipeline(
76
  DiffusionPipeline,
77
  TextualInversionLoaderMixin,
78
+ LoraLoaderMixin,
79
  IPAdapterMixin,
80
  FromSingleFileMixin,
81
  ):
 
87
 
88
  The pipeline also inherits the following loading methods:
89
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
90
+ - [`~loaders.LoraLoaderMixin.load_lora_weights`] for loading LoRA weights
91
+ - [`~loaders.LoraLoaderMixin.save_lora_weights`] for saving LoRA weights
92
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
93
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
94
 
 
286
  """
287
  # set lora scale so that monkey patched LoRA
288
  # function of text encoder can correctly access it
289
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
290
  self._lora_scale = lora_scale
291
 
292
  # dynamically adjust the LoRA scale
 
420
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
421
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
422
 
423
+ if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
424
  # Retrieve the original scale by scaling back the LoRA layers
425
  unscale_lora_layers(self.text_encoder, lora_scale)
426
 
main/pipeline_stable_diffusion_boxdiff.py CHANGED
@@ -27,12 +27,7 @@ from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, CLIPV
27
 
28
  from diffusers.configuration_utils import FrozenDict
29
  from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
30
- from diffusers.loaders import (
31
- FromSingleFileMixin,
32
- IPAdapterMixin,
33
- StableDiffusionLoraLoaderMixin,
34
- TextualInversionLoaderMixin,
35
- )
36
  from diffusers.models import AutoencoderKL, ImageProjection, UNet2DConditionModel
37
  from diffusers.models.attention_processor import Attention, FusedAttnProcessor2_0
38
  from diffusers.models.lora import adjust_lora_scale_text_encoder
@@ -363,7 +358,7 @@ def retrieve_timesteps(
363
 
364
 
365
  class StableDiffusionBoxDiffPipeline(
366
- DiffusionPipeline, TextualInversionLoaderMixin, StableDiffusionLoraLoaderMixin, IPAdapterMixin, FromSingleFileMixin
367
  ):
368
  r"""
369
  Pipeline for text-to-image generation using Stable Diffusion with BoxDiff.
@@ -373,8 +368,8 @@ class StableDiffusionBoxDiffPipeline(
373
 
374
  The pipeline also inherits the following loading methods:
375
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
376
- - [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`] for loading LoRA weights
377
- - [`~loaders.StableDiffusionLoraLoaderMixin.save_lora_weights`] for saving LoRA weights
378
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
379
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
380
 
@@ -599,7 +594,7 @@ class StableDiffusionBoxDiffPipeline(
599
  """
600
  # set lora scale so that monkey patched LoRA
601
  # function of text encoder can correctly access it
602
- if lora_scale is not None and isinstance(self, StableDiffusionLoraLoaderMixin):
603
  self._lora_scale = lora_scale
604
 
605
  # dynamically adjust the LoRA scale
@@ -731,7 +726,7 @@ class StableDiffusionBoxDiffPipeline(
731
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
732
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
733
 
734
- if isinstance(self, StableDiffusionLoraLoaderMixin) and USE_PEFT_BACKEND:
735
  # Retrieve the original scale by scaling back the LoRA layers
736
  unscale_lora_layers(self.text_encoder, lora_scale)
737
 
 
27
 
28
  from diffusers.configuration_utils import FrozenDict
29
  from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
30
+ from diffusers.loaders import FromSingleFileMixin, IPAdapterMixin, LoraLoaderMixin, TextualInversionLoaderMixin
 
 
 
 
 
31
  from diffusers.models import AutoencoderKL, ImageProjection, UNet2DConditionModel
32
  from diffusers.models.attention_processor import Attention, FusedAttnProcessor2_0
33
  from diffusers.models.lora import adjust_lora_scale_text_encoder
 
358
 
359
 
360
  class StableDiffusionBoxDiffPipeline(
361
+ DiffusionPipeline, TextualInversionLoaderMixin, LoraLoaderMixin, IPAdapterMixin, FromSingleFileMixin
362
  ):
363
  r"""
364
  Pipeline for text-to-image generation using Stable Diffusion with BoxDiff.
 
368
 
369
  The pipeline also inherits the following loading methods:
370
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
371
+ - [`~loaders.LoraLoaderMixin.load_lora_weights`] for loading LoRA weights
372
+ - [`~loaders.LoraLoaderMixin.save_lora_weights`] for saving LoRA weights
373
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
374
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
375
 
 
594
  """
595
  # set lora scale so that monkey patched LoRA
596
  # function of text encoder can correctly access it
597
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
598
  self._lora_scale = lora_scale
599
 
600
  # dynamically adjust the LoRA scale
 
726
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
727
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
728
 
729
+ if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
730
  # Retrieve the original scale by scaling back the LoRA layers
731
  unscale_lora_layers(self.text_encoder, lora_scale)
732
 
main/pipeline_stable_diffusion_pag.py CHANGED
@@ -11,12 +11,7 @@ from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, CLIPV
11
 
12
  from diffusers.configuration_utils import FrozenDict
13
  from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
14
- from diffusers.loaders import (
15
- FromSingleFileMixin,
16
- IPAdapterMixin,
17
- StableDiffusionLoraLoaderMixin,
18
- TextualInversionLoaderMixin,
19
- )
20
  from diffusers.models import AutoencoderKL, ImageProjection, UNet2DConditionModel
21
  from diffusers.models.attention_processor import Attention, AttnProcessor2_0, FusedAttnProcessor2_0
22
  from diffusers.models.lora import adjust_lora_scale_text_encoder
@@ -333,7 +328,7 @@ def retrieve_timesteps(
333
 
334
 
335
  class StableDiffusionPAGPipeline(
336
- DiffusionPipeline, TextualInversionLoaderMixin, StableDiffusionLoraLoaderMixin, IPAdapterMixin, FromSingleFileMixin
337
  ):
338
  r"""
339
  Pipeline for text-to-image generation using Stable Diffusion.
@@ -341,8 +336,8 @@ class StableDiffusionPAGPipeline(
341
  implemented for all pipelines (downloading, saving, running on a particular device, etc.).
342
  The pipeline also inherits the following loading methods:
343
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
344
- - [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`] for loading LoRA weights
345
- - [`~loaders.StableDiffusionLoraLoaderMixin.save_lora_weights`] for saving LoRA weights
346
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
347
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
348
  Args:
@@ -565,7 +560,7 @@ class StableDiffusionPAGPipeline(
565
  """
566
  # set lora scale so that monkey patched LoRA
567
  # function of text encoder can correctly access it
568
- if lora_scale is not None and isinstance(self, StableDiffusionLoraLoaderMixin):
569
  self._lora_scale = lora_scale
570
 
571
  # dynamically adjust the LoRA scale
@@ -697,7 +692,7 @@ class StableDiffusionPAGPipeline(
697
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
698
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
699
 
700
- if isinstance(self, StableDiffusionLoraLoaderMixin) and USE_PEFT_BACKEND:
701
  # Retrieve the original scale by scaling back the LoRA layers
702
  unscale_lora_layers(self.text_encoder, lora_scale)
703
 
 
11
 
12
  from diffusers.configuration_utils import FrozenDict
13
  from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
14
+ from diffusers.loaders import FromSingleFileMixin, IPAdapterMixin, LoraLoaderMixin, TextualInversionLoaderMixin
 
 
 
 
 
15
  from diffusers.models import AutoencoderKL, ImageProjection, UNet2DConditionModel
16
  from diffusers.models.attention_processor import Attention, AttnProcessor2_0, FusedAttnProcessor2_0
17
  from diffusers.models.lora import adjust_lora_scale_text_encoder
 
328
 
329
 
330
  class StableDiffusionPAGPipeline(
331
+ DiffusionPipeline, TextualInversionLoaderMixin, LoraLoaderMixin, IPAdapterMixin, FromSingleFileMixin
332
  ):
333
  r"""
334
  Pipeline for text-to-image generation using Stable Diffusion.
 
336
  implemented for all pipelines (downloading, saving, running on a particular device, etc.).
337
  The pipeline also inherits the following loading methods:
338
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
339
+ - [`~loaders.LoraLoaderMixin.load_lora_weights`] for loading LoRA weights
340
+ - [`~loaders.LoraLoaderMixin.save_lora_weights`] for saving LoRA weights
341
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
342
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
343
  Args:
 
560
  """
561
  # set lora scale so that monkey patched LoRA
562
  # function of text encoder can correctly access it
563
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
564
  self._lora_scale = lora_scale
565
 
566
  # dynamically adjust the LoRA scale
 
692
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
693
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
694
 
695
+ if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
696
  # Retrieve the original scale by scaling back the LoRA layers
697
  unscale_lora_layers(self.text_encoder, lora_scale)
698
 
main/pipeline_stable_diffusion_upscale_ldm3d.py CHANGED
@@ -22,7 +22,7 @@ from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
22
 
23
  from diffusers import DiffusionPipeline
24
  from diffusers.image_processor import PipelineDepthInput, PipelineImageInput, VaeImageProcessorLDM3D
25
- from diffusers.loaders import FromSingleFileMixin, StableDiffusionLoraLoaderMixin, TextualInversionLoaderMixin
26
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
27
  from diffusers.models.lora import adjust_lora_scale_text_encoder
28
  from diffusers.pipelines.stable_diffusion import StableDiffusionSafetyChecker
@@ -69,7 +69,7 @@ EXAMPLE_DOC_STRING = """
69
 
70
 
71
  class StableDiffusionUpscaleLDM3DPipeline(
72
- DiffusionPipeline, TextualInversionLoaderMixin, StableDiffusionLoraLoaderMixin, FromSingleFileMixin
73
  ):
74
  r"""
75
  Pipeline for text-to-image and 3D generation using LDM3D.
@@ -79,8 +79,8 @@ class StableDiffusionUpscaleLDM3DPipeline(
79
 
80
  The pipeline also inherits the following loading methods:
81
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
82
- - [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`] for loading LoRA weights
83
- - [`~loaders.StableDiffusionLoraLoaderMixin.save_lora_weights`] for saving LoRA weights
84
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
85
 
86
  Args:
@@ -233,7 +233,7 @@ class StableDiffusionUpscaleLDM3DPipeline(
233
  """
234
  # set lora scale so that monkey patched LoRA
235
  # function of text encoder can correctly access it
236
- if lora_scale is not None and isinstance(self, StableDiffusionLoraLoaderMixin):
237
  self._lora_scale = lora_scale
238
 
239
  # dynamically adjust the LoRA scale
@@ -365,7 +365,7 @@ class StableDiffusionUpscaleLDM3DPipeline(
365
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
366
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
367
 
368
- if isinstance(self, StableDiffusionLoraLoaderMixin) and USE_PEFT_BACKEND:
369
  # Retrieve the original scale by scaling back the LoRA layers
370
  unscale_lora_layers(self.text_encoder, lora_scale)
371
 
 
22
 
23
  from diffusers import DiffusionPipeline
24
  from diffusers.image_processor import PipelineDepthInput, PipelineImageInput, VaeImageProcessorLDM3D
25
+ from diffusers.loaders import FromSingleFileMixin, LoraLoaderMixin, TextualInversionLoaderMixin
26
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
27
  from diffusers.models.lora import adjust_lora_scale_text_encoder
28
  from diffusers.pipelines.stable_diffusion import StableDiffusionSafetyChecker
 
69
 
70
 
71
  class StableDiffusionUpscaleLDM3DPipeline(
72
+ DiffusionPipeline, TextualInversionLoaderMixin, LoraLoaderMixin, FromSingleFileMixin
73
  ):
74
  r"""
75
  Pipeline for text-to-image and 3D generation using LDM3D.
 
79
 
80
  The pipeline also inherits the following loading methods:
81
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
82
+ - [`~loaders.LoraLoaderMixin.load_lora_weights`] for loading LoRA weights
83
+ - [`~loaders.LoraLoaderMixin.save_lora_weights`] for saving LoRA weights
84
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
85
 
86
  Args:
 
233
  """
234
  # set lora scale so that monkey patched LoRA
235
  # function of text encoder can correctly access it
236
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
237
  self._lora_scale = lora_scale
238
 
239
  # dynamically adjust the LoRA scale
 
365
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
366
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
367
 
368
+ if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
369
  # Retrieve the original scale by scaling back the LoRA layers
370
  unscale_lora_layers(self.text_encoder, lora_scale)
371
 
main/pipeline_stable_diffusion_xl_controlnet_adapter_inpaint.py CHANGED
@@ -33,7 +33,7 @@ from diffusers import DiffusionPipeline
33
  from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
34
  from diffusers.loaders import (
35
  FromSingleFileMixin,
36
- StableDiffusionLoraLoaderMixin,
37
  StableDiffusionXLLoraLoaderMixin,
38
  TextualInversionLoaderMixin,
39
  )
@@ -300,7 +300,7 @@ def rescale_noise_cfg(noise_cfg, noise_pred_text, guidance_rescale=0.0):
300
 
301
 
302
  class StableDiffusionXLControlNetAdapterInpaintPipeline(
303
- DiffusionPipeline, StableDiffusionMixin, FromSingleFileMixin, StableDiffusionLoraLoaderMixin
304
  ):
305
  r"""
306
  Pipeline for text-to-image generation using Stable Diffusion augmented with T2I-Adapter
 
33
  from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
34
  from diffusers.loaders import (
35
  FromSingleFileMixin,
36
+ LoraLoaderMixin,
37
  StableDiffusionXLLoraLoaderMixin,
38
  TextualInversionLoaderMixin,
39
  )
 
300
 
301
 
302
  class StableDiffusionXLControlNetAdapterInpaintPipeline(
303
+ DiffusionPipeline, StableDiffusionMixin, FromSingleFileMixin, LoraLoaderMixin
304
  ):
305
  r"""
306
  Pipeline for text-to-image generation using Stable Diffusion augmented with T2I-Adapter
main/pipeline_stable_diffusion_xl_differential_img2img.py CHANGED
@@ -178,11 +178,11 @@ class StableDiffusionXLDifferentialImg2ImgPipeline(
178
 
179
  In addition the pipeline inherits the following loading methods:
180
  - *Textual-Inversion*: [`loaders.TextualInversionLoaderMixin.load_textual_inversion`]
181
- - *LoRA*: [`loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`]
182
  - *Ckpt*: [`loaders.FromSingleFileMixin.from_single_file`]
183
 
184
  as well as the following saving methods:
185
- - *LoRA*: [`loaders.StableDiffusionLoraLoaderMixin.save_lora_weights`]
186
 
187
  Args:
188
  vae ([`AutoencoderKL`]):
 
178
 
179
  In addition the pipeline inherits the following loading methods:
180
  - *Textual-Inversion*: [`loaders.TextualInversionLoaderMixin.load_textual_inversion`]
181
+ - *LoRA*: [`loaders.LoraLoaderMixin.load_lora_weights`]
182
  - *Ckpt*: [`loaders.FromSingleFileMixin.from_single_file`]
183
 
184
  as well as the following saving methods:
185
+ - *LoRA*: [`loaders.LoraLoaderMixin.save_lora_weights`]
186
 
187
  Args:
188
  vae ([`AutoencoderKL`]):
main/sde_drag.py CHANGED
@@ -11,7 +11,7 @@ from tqdm.auto import tqdm
11
  from transformers import CLIPTextModel, CLIPTokenizer
12
 
13
  from diffusers import AutoencoderKL, DiffusionPipeline, DPMSolverMultistepScheduler, UNet2DConditionModel
14
- from diffusers.loaders import AttnProcsLayers, StableDiffusionLoraLoaderMixin
15
  from diffusers.models.attention_processor import (
16
  AttnAddedKVProcessor,
17
  AttnAddedKVProcessor2_0,
@@ -321,7 +321,7 @@ class SdeDragPipeline(DiffusionPipeline):
321
  optimizer.zero_grad()
322
 
323
  with tempfile.TemporaryDirectory() as save_lora_dir:
324
- StableDiffusionLoraLoaderMixin.save_lora_weights(
325
  save_directory=save_lora_dir,
326
  unet_lora_layers=unet_lora_layers,
327
  text_encoder_lora_layers=None,
 
11
  from transformers import CLIPTextModel, CLIPTokenizer
12
 
13
  from diffusers import AutoencoderKL, DiffusionPipeline, DPMSolverMultistepScheduler, UNet2DConditionModel
14
+ from diffusers.loaders import AttnProcsLayers, LoraLoaderMixin
15
  from diffusers.models.attention_processor import (
16
  AttnAddedKVProcessor,
17
  AttnAddedKVProcessor2_0,
 
321
  optimizer.zero_grad()
322
 
323
  with tempfile.TemporaryDirectory() as save_lora_dir:
324
+ LoraLoaderMixin.save_lora_weights(
325
  save_directory=save_lora_dir,
326
  unet_lora_layers=unet_lora_layers,
327
  text_encoder_lora_layers=None,
main/stable_diffusion_ipex.py CHANGED
@@ -21,7 +21,7 @@ from packaging import version
21
  from transformers import CLIPFeatureExtractor, CLIPTextModel, CLIPTokenizer
22
 
23
  from diffusers.configuration_utils import FrozenDict
24
- from diffusers.loaders import StableDiffusionLoraLoaderMixin, TextualInversionLoaderMixin
25
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
26
  from diffusers.pipelines.pipeline_utils import DiffusionPipeline, StableDiffusionMixin
27
  from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
@@ -61,7 +61,7 @@ EXAMPLE_DOC_STRING = """
61
 
62
 
63
  class StableDiffusionIPEXPipeline(
64
- DiffusionPipeline, StableDiffusionMixin, TextualInversionLoaderMixin, StableDiffusionLoraLoaderMixin
65
  ):
66
  r"""
67
  Pipeline for text-to-image generation using Stable Diffusion on IPEX.
 
21
  from transformers import CLIPFeatureExtractor, CLIPTextModel, CLIPTokenizer
22
 
23
  from diffusers.configuration_utils import FrozenDict
24
+ from diffusers.loaders import LoraLoaderMixin, TextualInversionLoaderMixin
25
  from diffusers.models import AutoencoderKL, UNet2DConditionModel
26
  from diffusers.pipelines.pipeline_utils import DiffusionPipeline, StableDiffusionMixin
27
  from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
 
61
 
62
 
63
  class StableDiffusionIPEXPipeline(
64
+ DiffusionPipeline, StableDiffusionMixin, TextualInversionLoaderMixin, LoraLoaderMixin
65
  ):
66
  r"""
67
  Pipeline for text-to-image generation using Stable Diffusion on IPEX.
main/stable_diffusion_reference.py CHANGED
@@ -11,12 +11,7 @@ from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
11
  from diffusers import AutoencoderKL, DiffusionPipeline, UNet2DConditionModel
12
  from diffusers.configuration_utils import FrozenDict, deprecate
13
  from diffusers.image_processor import VaeImageProcessor
14
- from diffusers.loaders import (
15
- FromSingleFileMixin,
16
- IPAdapterMixin,
17
- StableDiffusionLoraLoaderMixin,
18
- TextualInversionLoaderMixin,
19
- )
20
  from diffusers.models.attention import BasicTransformerBlock
21
  from diffusers.models.lora import adjust_lora_scale_text_encoder
22
  from diffusers.models.unets.unet_2d_blocks import CrossAttnDownBlock2D, CrossAttnUpBlock2D, DownBlock2D, UpBlock2D
@@ -81,7 +76,7 @@ def torch_dfs(model: torch.nn.Module):
81
 
82
 
83
  class StableDiffusionReferencePipeline(
84
- DiffusionPipeline, TextualInversionLoaderMixin, StableDiffusionLoraLoaderMixin, IPAdapterMixin, FromSingleFileMixin
85
  ):
86
  r"""
87
  Pipeline for Stable Diffusion Reference.
@@ -91,8 +86,8 @@ class StableDiffusionReferencePipeline(
91
 
92
  The pipeline also inherits the following loading methods:
93
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
94
- - [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`] for loading LoRA weights
95
- - [`~loaders.StableDiffusionLoraLoaderMixin.save_lora_weights`] for saving LoRA weights
96
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
97
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
98
 
@@ -448,7 +443,7 @@ class StableDiffusionReferencePipeline(
448
  """
449
  # set lora scale so that monkey patched LoRA
450
  # function of text encoder can correctly access it
451
- if lora_scale is not None and isinstance(self, StableDiffusionLoraLoaderMixin):
452
  self._lora_scale = lora_scale
453
 
454
  # dynamically adjust the LoRA scale
@@ -580,7 +575,7 @@ class StableDiffusionReferencePipeline(
580
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
581
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
582
 
583
- if isinstance(self, StableDiffusionLoraLoaderMixin) and USE_PEFT_BACKEND:
584
  # Retrieve the original scale by scaling back the LoRA layers
585
  unscale_lora_layers(self.text_encoder, lora_scale)
586
 
 
11
  from diffusers import AutoencoderKL, DiffusionPipeline, UNet2DConditionModel
12
  from diffusers.configuration_utils import FrozenDict, deprecate
13
  from diffusers.image_processor import VaeImageProcessor
14
+ from diffusers.loaders import FromSingleFileMixin, IPAdapterMixin, LoraLoaderMixin, TextualInversionLoaderMixin
 
 
 
 
 
15
  from diffusers.models.attention import BasicTransformerBlock
16
  from diffusers.models.lora import adjust_lora_scale_text_encoder
17
  from diffusers.models.unets.unet_2d_blocks import CrossAttnDownBlock2D, CrossAttnUpBlock2D, DownBlock2D, UpBlock2D
 
76
 
77
 
78
  class StableDiffusionReferencePipeline(
79
+ DiffusionPipeline, TextualInversionLoaderMixin, LoraLoaderMixin, IPAdapterMixin, FromSingleFileMixin
80
  ):
81
  r"""
82
  Pipeline for Stable Diffusion Reference.
 
86
 
87
  The pipeline also inherits the following loading methods:
88
  - [`~loaders.TextualInversionLoaderMixin.load_textual_inversion`] for loading textual inversion embeddings
89
+ - [`~loaders.LoraLoaderMixin.load_lora_weights`] for loading LoRA weights
90
+ - [`~loaders.LoraLoaderMixin.save_lora_weights`] for saving LoRA weights
91
  - [`~loaders.FromSingleFileMixin.from_single_file`] for loading `.ckpt` files
92
  - [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
93
 
 
443
  """
444
  # set lora scale so that monkey patched LoRA
445
  # function of text encoder can correctly access it
446
+ if lora_scale is not None and isinstance(self, LoraLoaderMixin):
447
  self._lora_scale = lora_scale
448
 
449
  # dynamically adjust the LoRA scale
 
575
  negative_prompt_embeds = negative_prompt_embeds.repeat(1, num_images_per_prompt, 1)
576
  negative_prompt_embeds = negative_prompt_embeds.view(batch_size * num_images_per_prompt, seq_len, -1)
577
 
578
+ if isinstance(self, LoraLoaderMixin) and USE_PEFT_BACKEND:
579
  # Retrieve the original scale by scaling back the LoRA layers
580
  unscale_lora_layers(self.text_encoder, lora_scale)
581
 
main/stable_diffusion_repaint.py CHANGED
@@ -23,7 +23,7 @@ from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
23
 
24
  from diffusers import AutoencoderKL, DiffusionPipeline, UNet2DConditionModel
25
  from diffusers.configuration_utils import FrozenDict, deprecate
26
- from diffusers.loaders import StableDiffusionLoraLoaderMixin, TextualInversionLoaderMixin
27
  from diffusers.pipelines.pipeline_utils import StableDiffusionMixin
28
  from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
29
  from diffusers.pipelines.stable_diffusion.safety_checker import (
@@ -140,7 +140,7 @@ def prepare_mask_and_masked_image(image, mask):
140
 
141
 
142
  class StableDiffusionRepaintPipeline(
143
- DiffusionPipeline, StableDiffusionMixin, TextualInversionLoaderMixin, StableDiffusionLoraLoaderMixin
144
  ):
145
  r"""
146
  Pipeline for text-guided image inpainting using Stable Diffusion. *This is an experimental feature*.
@@ -148,9 +148,9 @@ class StableDiffusionRepaintPipeline(
148
  library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)
149
  In addition the pipeline inherits the following loading methods:
150
  - *Textual-Inversion*: [`loaders.TextualInversionLoaderMixin.load_textual_inversion`]
151
- - *LoRA*: [`loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`]
152
  as well as the following saving methods:
153
- - *LoRA*: [`loaders.StableDiffusionLoraLoaderMixin.save_lora_weights`]
154
  Args:
155
  vae ([`AutoencoderKL`]):
156
  Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.
 
23
 
24
  from diffusers import AutoencoderKL, DiffusionPipeline, UNet2DConditionModel
25
  from diffusers.configuration_utils import FrozenDict, deprecate
26
+ from diffusers.loaders import LoraLoaderMixin, TextualInversionLoaderMixin
27
  from diffusers.pipelines.pipeline_utils import StableDiffusionMixin
28
  from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
29
  from diffusers.pipelines.stable_diffusion.safety_checker import (
 
140
 
141
 
142
  class StableDiffusionRepaintPipeline(
143
+ DiffusionPipeline, StableDiffusionMixin, TextualInversionLoaderMixin, LoraLoaderMixin
144
  ):
145
  r"""
146
  Pipeline for text-guided image inpainting using Stable Diffusion. *This is an experimental feature*.
 
148
  library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)
149
  In addition the pipeline inherits the following loading methods:
150
  - *Textual-Inversion*: [`loaders.TextualInversionLoaderMixin.load_textual_inversion`]
151
+ - *LoRA*: [`loaders.LoraLoaderMixin.load_lora_weights`]
152
  as well as the following saving methods:
153
+ - *LoRA*: [`loaders.LoraLoaderMixin.save_lora_weights`]
154
  Args:
155
  vae ([`AutoencoderKL`]):
156
  Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.