diff --git a/docs/source/en/api/pipelines/stable_diffusion/stable_diffusion_xl.md b/docs/source/en/api/pipelines/stable_diffusion/stable_diffusion_xl.md index 8da3e2f10727..8486641da2c4 100644 --- a/docs/source/en/api/pipelines/stable_diffusion/stable_diffusion_xl.md +++ b/docs/source/en/api/pipelines/stable_diffusion/stable_diffusion_xl.md @@ -38,9 +38,25 @@ You can install the libraries as follows: pip install transformers pip install accelerate pip install safetensors +``` + +### Watermarker + +We recommend to add an invisible watermark to images generating by Stable Diffusion XL, this can help with identifying if an image is machine-synthesised for downstream applications. To do so, please install +the [invisible-watermark library](https://pypi.org/project/invisible-watermark/) via: + +``` pip install invisible-watermark>=0.2.0 ``` +If the `invisible-watermark` library is installed the watermarker will be used **by default**. + +If you have other provisions for generating or deploying images safely, you can disable the watermarker as follows: + +```py +pipe = StableDiffusionXLPipeline.from_pretrained(..., add_watermarker=False) +``` + ### Text-to-Image You can use SDXL as follows for *text-to-image*: diff --git a/examples/controlnet/requirements_sdxl.txt b/examples/controlnet/requirements_sdxl.txt index 0192e03ddb4c..5ab6e9932e10 100644 --- a/examples/controlnet/requirements_sdxl.txt +++ b/examples/controlnet/requirements_sdxl.txt @@ -4,6 +4,5 @@ transformers>=4.25.1 ftfy tensorboard Jinja2 -invisible-watermark>=0.2.0 datasets wandb diff --git a/examples/dreambooth/requirements_sdxl.txt b/examples/dreambooth/requirements_sdxl.txt index 7a9936ee4003..7a612982f4ab 100644 --- a/examples/dreambooth/requirements_sdxl.txt +++ b/examples/dreambooth/requirements_sdxl.txt @@ -4,4 +4,3 @@ transformers>=4.25.1 ftfy tensorboard Jinja2 -invisible-watermark>=0.2.0 \ No newline at end of file diff --git a/src/diffusers/__init__.py b/src/diffusers/__init__.py index 820aae1ddb15..56b530285ac1 100644 --- a/src/diffusers/__init__.py +++ b/src/diffusers/__init__.py @@ -185,6 +185,11 @@ StableDiffusionPix2PixZeroPipeline, StableDiffusionSAGPipeline, StableDiffusionUpscalePipeline, + StableDiffusionXLControlNetPipeline, + StableDiffusionXLImg2ImgPipeline, + StableDiffusionXLInpaintPipeline, + StableDiffusionXLInstructPix2PixPipeline, + StableDiffusionXLPipeline, StableUnCLIPImg2ImgPipeline, StableUnCLIPPipeline, TextToVideoSDPipeline, @@ -202,20 +207,6 @@ VQDiffusionPipeline, ) -try: - if not (is_torch_available() and is_transformers_available() and is_invisible_watermark_available()): - raise OptionalDependencyNotAvailable() -except OptionalDependencyNotAvailable: - from .utils.dummy_torch_and_transformers_and_invisible_watermark_objects import * # noqa F403 -else: - from .pipelines import ( - StableDiffusionXLControlNetPipeline, - StableDiffusionXLImg2ImgPipeline, - StableDiffusionXLInpaintPipeline, - StableDiffusionXLInstructPix2PixPipeline, - StableDiffusionXLPipeline, - ) - try: if not (is_torch_available() and is_transformers_available() and is_k_diffusion_available()): raise OptionalDependencyNotAvailable() diff --git a/src/diffusers/pipelines/__init__.py b/src/diffusers/pipelines/__init__.py index a22da6373181..2e8cee9ce697 100644 --- a/src/diffusers/pipelines/__init__.py +++ b/src/diffusers/pipelines/__init__.py @@ -1,7 +1,6 @@ from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, - is_invisible_watermark_available, is_k_diffusion_available, is_librosa_available, is_note_seq_available, @@ -51,6 +50,7 @@ StableDiffusionControlNetImg2ImgPipeline, StableDiffusionControlNetInpaintPipeline, StableDiffusionControlNetPipeline, + StableDiffusionXLControlNetPipeline, ) from .deepfloyd_if import ( IFImg2ImgPipeline, @@ -108,6 +108,12 @@ StableUnCLIPPipeline, ) from .stable_diffusion_safe import StableDiffusionPipelineSafe + from .stable_diffusion_xl import ( + StableDiffusionXLImg2ImgPipeline, + StableDiffusionXLInpaintPipeline, + StableDiffusionXLInstructPix2PixPipeline, + StableDiffusionXLPipeline, + ) from .t2i_adapter import StableDiffusionAdapterPipeline from .text_to_video_synthesis import TextToVideoSDPipeline, TextToVideoZeroPipeline, VideoToVideoSDPipeline from .unclip import UnCLIPImageVariationPipeline, UnCLIPPipeline @@ -121,20 +127,6 @@ from .vq_diffusion import VQDiffusionPipeline -try: - if not (is_torch_available() and is_transformers_available() and is_invisible_watermark_available()): - raise OptionalDependencyNotAvailable() -except OptionalDependencyNotAvailable: - from ..utils.dummy_torch_and_transformers_and_invisible_watermark_objects import * # noqa F403 -else: - from .controlnet import StableDiffusionXLControlNetPipeline - from .stable_diffusion_xl import ( - StableDiffusionXLImg2ImgPipeline, - StableDiffusionXLInpaintPipeline, - StableDiffusionXLInstructPix2PixPipeline, - StableDiffusionXLPipeline, - ) - try: if not is_onnx_available(): raise OptionalDependencyNotAvailable() diff --git a/src/diffusers/pipelines/controlnet/__init__.py b/src/diffusers/pipelines/controlnet/__init__.py index 83a4b37f0441..d5f7eb6b4fcc 100644 --- a/src/diffusers/pipelines/controlnet/__init__.py +++ b/src/diffusers/pipelines/controlnet/__init__.py @@ -1,21 +1,11 @@ from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, - is_invisible_watermark_available, is_torch_available, is_transformers_available, ) -try: - if not (is_transformers_available() and is_torch_available() and is_invisible_watermark_available()): - raise OptionalDependencyNotAvailable() -except OptionalDependencyNotAvailable: - from ...utils.dummy_torch_and_transformers_and_invisible_watermark_objects import * # noqa F403 -else: - from .pipeline_controlnet_sd_xl import StableDiffusionXLControlNetPipeline - - try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() @@ -26,6 +16,7 @@ from .pipeline_controlnet import StableDiffusionControlNetPipeline from .pipeline_controlnet_img2img import StableDiffusionControlNetImg2ImgPipeline from .pipeline_controlnet_inpaint import StableDiffusionControlNetInpaintPipeline + from .pipeline_controlnet_sd_xl import StableDiffusionXLControlNetPipeline if is_transformers_available() and is_flax_available(): diff --git a/src/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py b/src/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py index ac93d19f5b91..37723e6e3b2a 100644 --- a/src/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py +++ b/src/diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py @@ -22,6 +22,8 @@ import torch.nn.functional as F from transformers import CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer +from diffusers.utils.import_utils import is_invisible_watermark_available + from ...image_processor import VaeImageProcessor from ...loaders import LoraLoaderMixin, TextualInversionLoaderMixin from ...models import AutoencoderKL, ControlNetModel, UNet2DConditionModel @@ -42,7 +44,11 @@ ) from ..pipeline_utils import DiffusionPipeline from ..stable_diffusion_xl import StableDiffusionXLPipelineOutput -from ..stable_diffusion_xl.watermark import StableDiffusionXLWatermarker + + +if is_invisible_watermark_available(): + from ..stable_diffusion_xl.watermark import StableDiffusionXLWatermarker + from .multicontrolnet import MultiControlNetModel @@ -109,6 +115,7 @@ def __init__( controlnet: ControlNetModel, scheduler: KarrasDiffusionSchedulers, force_zeros_for_empty_prompt: bool = True, + add_watermarker: Optional[bool] = None, ): super().__init__() @@ -130,7 +137,13 @@ def __init__( self.control_image_processor = VaeImageProcessor( vae_scale_factor=self.vae_scale_factor, do_convert_rgb=True, do_normalize=False ) - self.watermark = StableDiffusionXLWatermarker() + add_watermarker = add_watermarker if add_watermarker is not None else is_invisible_watermark_available() + + if add_watermarker: + self.watermark = StableDiffusionXLWatermarker() + else: + self.watermark = None + self.register_to_config(force_zeros_for_empty_prompt=force_zeros_for_empty_prompt) # Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.enable_vae_slicing @@ -995,7 +1008,10 @@ def __call__( image = latents return StableDiffusionXLPipelineOutput(images=image) - image = self.watermark.apply_watermark(image) + # apply watermark if available + if self.watermark is not None: + image = self.watermark.apply_watermark(image) + image = self.image_processor.postprocess(image, output_type=output_type) # Offload last model to CPU diff --git a/src/diffusers/pipelines/stable_diffusion_xl/__init__.py b/src/diffusers/pipelines/stable_diffusion_xl/__init__.py index f2994f7d7d2d..7c714adaca49 100644 --- a/src/diffusers/pipelines/stable_diffusion_xl/__init__.py +++ b/src/diffusers/pipelines/stable_diffusion_xl/__init__.py @@ -7,7 +7,6 @@ from ...utils import ( BaseOutput, OptionalDependencyNotAvailable, - is_invisible_watermark_available, is_torch_available, is_transformers_available, ) @@ -28,10 +27,10 @@ class StableDiffusionXLPipelineOutput(BaseOutput): try: - if not (is_transformers_available() and is_torch_available() and is_invisible_watermark_available()): + if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: - from ...utils.dummy_torch_and_transformers_and_invisible_watermark_objects import * # noqa F403 + from ...utils.dummy_torch_and_transformers_and_objects import * # noqa F403 else: from .pipeline_stable_diffusion_xl import StableDiffusionXLPipeline from .pipeline_stable_diffusion_xl_img2img import StableDiffusionXLImg2ImgPipeline diff --git a/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py b/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py index 0db2ec81ec62..9c19ba19b3e6 100644 --- a/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py +++ b/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py @@ -32,13 +32,17 @@ from ...utils import ( is_accelerate_available, is_accelerate_version, + is_invisible_watermark_available, logging, randn_tensor, replace_example_docstring, ) from ..pipeline_utils import DiffusionPipeline from . import StableDiffusionXLPipelineOutput -from .watermark import StableDiffusionXLWatermarker + + +if is_invisible_watermark_available(): + from .watermark import StableDiffusionXLWatermarker logger = logging.get_logger(__name__) # pylint: disable=invalid-name @@ -125,6 +129,7 @@ def __init__( unet: UNet2DConditionModel, scheduler: KarrasDiffusionSchedulers, force_zeros_for_empty_prompt: bool = True, + add_watermarker: Optional[bool] = None, ): super().__init__() @@ -142,7 +147,12 @@ def __init__( self.image_processor = VaeImageProcessor(vae_scale_factor=self.vae_scale_factor) self.default_sample_size = self.unet.config.sample_size - self.watermark = StableDiffusionXLWatermarker() + add_watermarker = add_watermarker if add_watermarker is not None else is_invisible_watermark_available() + + if add_watermarker: + self.watermark = StableDiffusionXLWatermarker() + else: + self.watermark = None # Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.enable_vae_slicing def enable_vae_slicing(self): @@ -839,7 +849,10 @@ def __call__( image = latents return StableDiffusionXLPipelineOutput(images=image) - image = self.watermark.apply_watermark(image) + # apply watermark if available + if self.watermark is not None: + image = self.watermark.apply_watermark(image) + image = self.image_processor.postprocess(image, output_type=output_type) # Offload last model to CPU diff --git a/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py b/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py index 89bc34a6471e..fb0c07321e53 100644 --- a/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py +++ b/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py @@ -33,13 +33,17 @@ from ...utils import ( is_accelerate_available, is_accelerate_version, + is_invisible_watermark_available, logging, randn_tensor, replace_example_docstring, ) from ..pipeline_utils import DiffusionPipeline from . import StableDiffusionXLPipelineOutput -from .watermark import StableDiffusionXLWatermarker + + +if is_invisible_watermark_available(): + from .watermark import StableDiffusionXLWatermarker logger = logging.get_logger(__name__) # pylint: disable=invalid-name @@ -131,6 +135,7 @@ def __init__( scheduler: KarrasDiffusionSchedulers, requires_aesthetics_score: bool = False, force_zeros_for_empty_prompt: bool = True, + add_watermarker: Optional[bool] = None, ): super().__init__() @@ -148,7 +153,12 @@ def __init__( self.vae_scale_factor = 2 ** (len(self.vae.config.block_out_channels) - 1) self.image_processor = VaeImageProcessor(vae_scale_factor=self.vae_scale_factor) - self.watermark = StableDiffusionXLWatermarker() + add_watermarker = add_watermarker if add_watermarker is not None else is_invisible_watermark_available() + + if add_watermarker: + self.watermark = StableDiffusionXLWatermarker() + else: + self.watermark = None # Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.enable_vae_slicing def enable_vae_slicing(self): @@ -990,7 +1000,10 @@ def denoising_value_valid(dnv): image = latents return StableDiffusionXLPipelineOutput(images=image) - image = self.watermark.apply_watermark(image) + # apply watermark if available + if self.watermark is not None: + image = self.watermark.apply_watermark(image) + image = self.image_processor.postprocess(image, output_type=output_type) # Offload last model to CPU diff --git a/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py b/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py index cd51618e4eeb..77038f3f3ce9 100644 --- a/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py +++ b/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py @@ -30,10 +30,20 @@ XFormersAttnProcessor, ) from ...schedulers import KarrasDiffusionSchedulers -from ...utils import is_accelerate_available, is_accelerate_version, logging, randn_tensor, replace_example_docstring +from ...utils import ( + is_accelerate_available, + is_accelerate_version, + is_invisible_watermark_available, + logging, + randn_tensor, + replace_example_docstring, +) from ..pipeline_utils import DiffusionPipeline from . import StableDiffusionXLPipelineOutput -from .watermark import StableDiffusionXLWatermarker + + +if is_invisible_watermark_available(): + from .watermark import StableDiffusionXLWatermarker logger = logging.get_logger(__name__) # pylint: disable=invalid-name @@ -265,6 +275,7 @@ def __init__( scheduler: KarrasDiffusionSchedulers, requires_aesthetics_score: bool = False, force_zeros_for_empty_prompt: bool = True, + add_watermarker: Optional[bool] = None, ): super().__init__() @@ -282,7 +293,12 @@ def __init__( self.vae_scale_factor = 2 ** (len(self.vae.config.block_out_channels) - 1) self.image_processor = VaeImageProcessor(vae_scale_factor=self.vae_scale_factor) - self.watermark = StableDiffusionXLWatermarker() + add_watermarker = add_watermarker if add_watermarker is not None else is_invisible_watermark_available() + + if add_watermarker: + self.watermark = StableDiffusionXLWatermarker() + else: + self.watermark = None # Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline.enable_vae_slicing def enable_vae_slicing(self): @@ -1266,6 +1282,10 @@ def denoising_value_valid(dnv): else: return StableDiffusionXLPipelineOutput(images=latents) + # apply watermark if available + if self.watermark is not None: + image = self.watermark.apply_watermark(image) + image = self.image_processor.postprocess(image, output_type=output_type) # Offload last model to CPU diff --git a/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_instruct_pix2pix.py b/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_instruct_pix2pix.py index 15371cd0b01f..68d7ecfa512b 100644 --- a/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_instruct_pix2pix.py +++ b/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_instruct_pix2pix.py @@ -34,12 +34,16 @@ deprecate, is_accelerate_available, is_accelerate_version, + is_invisible_watermark_available, logging, randn_tensor, ) from ..pipeline_utils import DiffusionPipeline from . import StableDiffusionXLPipelineOutput -from .watermark import StableDiffusionXLWatermarker + + +if is_invisible_watermark_available(): + from .watermark import StableDiffusionXLWatermarker logger = logging.get_logger(__name__) # pylint: disable=invalid-name @@ -109,6 +113,7 @@ def __init__( scheduler: KarrasDiffusionSchedulers, requires_aesthetics_score: bool = False, force_zeros_for_empty_prompt: bool = True, + add_watermarker: Optional[bool] = None, ): super().__init__() @@ -128,7 +133,12 @@ def __init__( self.vae.config.force_upcast = True # force the VAE to be in float32 mode, as it overflows in float16 - self.watermark = StableDiffusionXLWatermarker() + add_watermarker = add_watermarker if add_watermarker is not None else is_invisible_watermark_available() + + if add_watermarker: + self.watermark = StableDiffusionXLWatermarker() + else: + self.watermark = None def enable_vae_slicing(self): r""" @@ -908,7 +918,10 @@ def __call__( image = latents return StableDiffusionXLPipelineOutput(images=image) - image = self.watermark.apply_watermark(image) + # apply watermark if available + if self.watermark is not None: + image = self.watermark.apply_watermark(image) + image = self.image_processor.postprocess(image, output_type=output_type) # Offload last model to CPU diff --git a/src/diffusers/pipelines/stable_diffusion_xl/watermark.py b/src/diffusers/pipelines/stable_diffusion_xl/watermark.py index bc6c9bf649b1..5b6e36d9f447 100644 --- a/src/diffusers/pipelines/stable_diffusion_xl/watermark.py +++ b/src/diffusers/pipelines/stable_diffusion_xl/watermark.py @@ -1,6 +1,11 @@ import numpy as np import torch -from imwatermark import WatermarkEncoder + +from ...utils import is_invisible_watermark_available + + +if is_invisible_watermark_available(): + from imwatermark import WatermarkEncoder # Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66 diff --git a/src/diffusers/utils/dummy_torch_and_transformers_and_invisible_watermark_objects.py b/src/diffusers/utils/dummy_torch_and_transformers_and_invisible_watermark_objects.py deleted file mode 100644 index eae5528148a5..000000000000 --- a/src/diffusers/utils/dummy_torch_and_transformers_and_invisible_watermark_objects.py +++ /dev/null @@ -1,77 +0,0 @@ -# This file is autogenerated by the command `make fix-copies`, do not edit. -from ..utils import DummyObject, requires_backends - - -class StableDiffusionXLControlNetPipeline(metaclass=DummyObject): - _backends = ["torch", "transformers", "invisible_watermark"] - - def __init__(self, *args, **kwargs): - requires_backends(self, ["torch", "transformers", "invisible_watermark"]) - - @classmethod - def from_config(cls, *args, **kwargs): - requires_backends(cls, ["torch", "transformers", "invisible_watermark"]) - - @classmethod - def from_pretrained(cls, *args, **kwargs): - requires_backends(cls, ["torch", "transformers", "invisible_watermark"]) - - -class StableDiffusionXLImg2ImgPipeline(metaclass=DummyObject): - _backends = ["torch", "transformers", "invisible_watermark"] - - def __init__(self, *args, **kwargs): - requires_backends(self, ["torch", "transformers", "invisible_watermark"]) - - @classmethod - def from_config(cls, *args, **kwargs): - requires_backends(cls, ["torch", "transformers", "invisible_watermark"]) - - @classmethod - def from_pretrained(cls, *args, **kwargs): - requires_backends(cls, ["torch", "transformers", "invisible_watermark"]) - - -class StableDiffusionXLInpaintPipeline(metaclass=DummyObject): - _backends = ["torch", "transformers", "invisible_watermark"] - - def __init__(self, *args, **kwargs): - requires_backends(self, ["torch", "transformers", "invisible_watermark"]) - - @classmethod - def from_config(cls, *args, **kwargs): - requires_backends(cls, ["torch", "transformers", "invisible_watermark"]) - - @classmethod - def from_pretrained(cls, *args, **kwargs): - requires_backends(cls, ["torch", "transformers", "invisible_watermark"]) - - -class StableDiffusionXLInstructPix2PixPipeline(metaclass=DummyObject): - _backends = ["torch", "transformers", "invisible_watermark"] - - def __init__(self, *args, **kwargs): - requires_backends(self, ["torch", "transformers", "invisible_watermark"]) - - @classmethod - def from_config(cls, *args, **kwargs): - requires_backends(cls, ["torch", "transformers", "invisible_watermark"]) - - @classmethod - def from_pretrained(cls, *args, **kwargs): - requires_backends(cls, ["torch", "transformers", "invisible_watermark"]) - - -class StableDiffusionXLPipeline(metaclass=DummyObject): - _backends = ["torch", "transformers", "invisible_watermark"] - - def __init__(self, *args, **kwargs): - requires_backends(self, ["torch", "transformers", "invisible_watermark"]) - - @classmethod - def from_config(cls, *args, **kwargs): - requires_backends(cls, ["torch", "transformers", "invisible_watermark"]) - - @classmethod - def from_pretrained(cls, *args, **kwargs): - requires_backends(cls, ["torch", "transformers", "invisible_watermark"]) diff --git a/src/diffusers/utils/dummy_torch_and_transformers_objects.py b/src/diffusers/utils/dummy_torch_and_transformers_objects.py index 254b99e85c05..df8009dd0e27 100644 --- a/src/diffusers/utils/dummy_torch_and_transformers_objects.py +++ b/src/diffusers/utils/dummy_torch_and_transformers_objects.py @@ -827,6 +827,81 @@ def from_pretrained(cls, *args, **kwargs): requires_backends(cls, ["torch", "transformers"]) +class StableDiffusionXLControlNetPipeline(metaclass=DummyObject): + _backends = ["torch", "transformers"] + + def __init__(self, *args, **kwargs): + requires_backends(self, ["torch", "transformers"]) + + @classmethod + def from_config(cls, *args, **kwargs): + requires_backends(cls, ["torch", "transformers"]) + + @classmethod + def from_pretrained(cls, *args, **kwargs): + requires_backends(cls, ["torch", "transformers"]) + + +class StableDiffusionXLImg2ImgPipeline(metaclass=DummyObject): + _backends = ["torch", "transformers"] + + def __init__(self, *args, **kwargs): + requires_backends(self, ["torch", "transformers"]) + + @classmethod + def from_config(cls, *args, **kwargs): + requires_backends(cls, ["torch", "transformers"]) + + @classmethod + def from_pretrained(cls, *args, **kwargs): + requires_backends(cls, ["torch", "transformers"]) + + +class StableDiffusionXLInpaintPipeline(metaclass=DummyObject): + _backends = ["torch", "transformers"] + + def __init__(self, *args, **kwargs): + requires_backends(self, ["torch", "transformers"]) + + @classmethod + def from_config(cls, *args, **kwargs): + requires_backends(cls, ["torch", "transformers"]) + + @classmethod + def from_pretrained(cls, *args, **kwargs): + requires_backends(cls, ["torch", "transformers"]) + + +class StableDiffusionXLInstructPix2PixPipeline(metaclass=DummyObject): + _backends = ["torch", "transformers"] + + def __init__(self, *args, **kwargs): + requires_backends(self, ["torch", "transformers"]) + + @classmethod + def from_config(cls, *args, **kwargs): + requires_backends(cls, ["torch", "transformers"]) + + @classmethod + def from_pretrained(cls, *args, **kwargs): + requires_backends(cls, ["torch", "transformers"]) + + +class StableDiffusionXLPipeline(metaclass=DummyObject): + _backends = ["torch", "transformers"] + + def __init__(self, *args, **kwargs): + requires_backends(self, ["torch", "transformers"]) + + @classmethod + def from_config(cls, *args, **kwargs): + requires_backends(cls, ["torch", "transformers"]) + + @classmethod + def from_pretrained(cls, *args, **kwargs): + requires_backends(cls, ["torch", "transformers"]) + + class StableUnCLIPImg2ImgPipeline(metaclass=DummyObject): _backends = ["torch", "transformers"]