|
23 | 23 | from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
|
24 | 24 |
|
25 | 25 | from ...configuration_utils import FrozenDict
|
26 |
| -from ...loaders import TextualInversionLoaderMixin |
| 26 | +from ...loaders import LoraLoaderMixin, TextualInversionLoaderMixin |
27 | 27 | from ...models import AutoencoderKL, UNet2DConditionModel
|
28 | 28 | from ...schedulers import DDIMInverseScheduler, KarrasDiffusionSchedulers
|
29 | 29 | from ...utils import (
|
@@ -230,13 +230,20 @@ def preprocess_mask(mask, batch_size: int = 1):
|
230 | 230 | return mask
|
231 | 231 |
|
232 | 232 |
|
233 |
| -class StableDiffusionDiffEditPipeline(DiffusionPipeline, TextualInversionLoaderMixin): |
| 233 | +class StableDiffusionDiffEditPipeline(DiffusionPipeline, TextualInversionLoaderMixin, LoraLoaderMixin): |
234 | 234 | r"""
|
235 | 235 | Pipeline for text-guided image inpainting using Stable Diffusion using DiffEdit. *This is an experimental feature*.
|
236 | 236 |
|
237 | 237 | This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods the
|
238 | 238 | library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)
|
239 | 239 |
|
| 240 | + In addition the pipeline inherits the following loading methods: |
| 241 | + - *Textual-Inversion*: [`loaders.TextualInversionLoaderMixin.load_textual_inversion`] |
| 242 | + - *LoRA*: [`loaders.LoraLoaderMixin.load_lora_weights`] |
| 243 | +
|
| 244 | + as well as the following saving methods: |
| 245 | + - *LoRA*: [`loaders.LoraLoaderMixin.save_lora_weights`] |
| 246 | +
|
240 | 247 | Args:
|
241 | 248 | vae ([`AutoencoderKL`]):
|
242 | 249 | Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.
|
@@ -771,6 +778,7 @@ def prepare_latents(self, batch_size, num_channels_latents, height, width, dtype
|
771 | 778 | latents = latents * self.scheduler.init_noise_sigma
|
772 | 779 | return latents
|
773 | 780 |
|
| 781 | + # Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_pix2pix_zero.prepare_image_latents |
774 | 782 | def prepare_image_latents(self, image, batch_size, dtype, device, generator=None):
|
775 | 783 | if not isinstance(image, (torch.Tensor, PIL.Image.Image, list)):
|
776 | 784 | raise ValueError(
|
|
0 commit comments