Diffusers BOINC AI docs
  • 🌍GET STARTED
    • Diffusers
    • Quicktour
    • Effective and efficient diffusion
    • Installation
  • 🌍TUTORIALS
    • Overview
    • Understanding models and schedulers
    • AutoPipeline
    • Train a diffusion model
  • 🌍USING DIFFUSERS
    • 🌍LOADING & HUB
      • Overview
      • Load pipelines, models, and schedulers
      • Load and compare different schedulers
      • Load community pipelines
      • Load safetensors
      • Load different Stable Diffusion formats
      • Push files to the Hub
    • 🌍TASKS
      • Unconditional image generation
      • Text-to-image
      • Image-to-image
      • Inpainting
      • Depth-to-image
    • 🌍TECHNIQUES
      • Textual inversion
      • Distributed inference with multiple GPUs
      • Improve image quality with deterministic generation
      • Control image brightness
      • Prompt weighting
    • 🌍PIPELINES FOR INFERENCE
      • Overview
      • Stable Diffusion XL
      • ControlNet
      • Shap-E
      • DiffEdit
      • Distilled Stable Diffusion inference
      • Create reproducible pipelines
      • Community pipelines
      • How to contribute a community pipeline
    • 🌍TRAINING
      • Overview
      • Create a dataset for training
      • Adapt a model to a new task
      • Unconditional image generation
      • Textual Inversion
      • DreamBooth
      • Text-to-image
      • Low-Rank Adaptation of Large Language Models (LoRA)
      • ControlNet
      • InstructPix2Pix Training
      • Custom Diffusion
      • T2I-Adapters
    • 🌍TAKING DIFFUSERS BEYOND IMAGES
      • Other Modalities
  • 🌍OPTIMIZATION/SPECIAL HARDWARE
    • Overview
    • Memory and Speed
    • Torch2.0 support
    • Stable Diffusion in JAX/Flax
    • xFormers
    • ONNX
    • OpenVINO
    • Core ML
    • MPS
    • Habana Gaudi
    • Token Merging
  • 🌍CONCEPTUAL GUIDES
    • Philosophy
    • Controlled generation
    • How to contribute?
    • Diffusers' Ethical Guidelines
    • Evaluating Diffusion Models
  • 🌍API
    • 🌍MAIN CLASSES
      • Attention Processor
      • Diffusion Pipeline
      • Logging
      • Configuration
      • Outputs
      • Loaders
      • Utilities
      • VAE Image Processor
    • 🌍MODELS
      • Overview
      • UNet1DModel
      • UNet2DModel
      • UNet2DConditionModel
      • UNet3DConditionModel
      • VQModel
      • AutoencoderKL
      • AsymmetricAutoencoderKL
      • Tiny AutoEncoder
      • Transformer2D
      • Transformer Temporal
      • Prior Transformer
      • ControlNet
    • 🌍PIPELINES
      • Overview
      • AltDiffusion
      • Attend-and-Excite
      • Audio Diffusion
      • AudioLDM
      • AudioLDM 2
      • AutoPipeline
      • Consistency Models
      • ControlNet
      • ControlNet with Stable Diffusion XL
      • Cycle Diffusion
      • Dance Diffusion
      • DDIM
      • DDPM
      • DeepFloyd IF
      • DiffEdit
      • DiT
      • IF
      • PaInstructPix2Pix
      • Kandinsky
      • Kandinsky 2.2
      • Latent Diffusionge
      • MultiDiffusion
      • MusicLDM
      • PaintByExample
      • Parallel Sampling of Diffusion Models
      • Pix2Pix Zero
      • PNDM
      • RePaint
      • Score SDE VE
      • Self-Attention Guidance
      • Semantic Guidance
      • Shap-E
      • Spectrogram Diffusion
      • 🌍STABLE DIFFUSION
        • Overview
        • Text-to-image
        • Image-to-image
        • Inpainting
        • Depth-to-image
        • Image variation
        • Safe Stable Diffusion
        • Stable Diffusion 2
        • Stable Diffusion XL
        • Latent upscaler
        • Super-resolution
        • LDM3D Text-to-(RGB, Depth)
        • Stable Diffusion T2I-adapter
        • GLIGEN (Grounded Language-to-Image Generation)
      • Stable unCLIP
      • Stochastic Karras VE
      • Text-to-image model editing
      • Text-to-video
      • Text2Video-Zero
      • UnCLIP
      • Unconditional Latent Diffusion
      • UniDiffuser
      • Value-guided sampling
      • Versatile Diffusion
      • VQ Diffusion
      • Wuerstchen
    • 🌍SCHEDULERS
      • Overview
      • CMStochasticIterativeScheduler
      • DDIMInverseScheduler
      • DDIMScheduler
      • DDPMScheduler
      • DEISMultistepScheduler
      • DPMSolverMultistepInverse
      • DPMSolverMultistepScheduler
      • DPMSolverSDEScheduler
      • DPMSolverSinglestepScheduler
      • EulerAncestralDiscreteScheduler
      • EulerDiscreteScheduler
      • HeunDiscreteScheduler
      • IPNDMScheduler
      • KarrasVeScheduler
      • KDPM2AncestralDiscreteScheduler
      • KDPM2DiscreteScheduler
      • LMSDiscreteScheduler
      • PNDMScheduler
      • RePaintScheduler
      • ScoreSdeVeScheduler
      • ScoreSdeVpScheduler
      • UniPCMultistepScheduler
      • VQDiffusionScheduler
Powered by GitBook
On this page
  • Versatile Diffusion
  • Tips
  • VersatileDiffusionPipeline
  • VersatileDiffusionTextToImagePipeline
  • VersatileDiffusionImageVariationPipeline
  • VersatileDiffusionDualGuidedPipeline
  1. API
  2. PIPELINES

Versatile Diffusion

PreviousValue-guided samplingNextVQ Diffusion

Last updated 1 year ago

Versatile Diffusion

Versatile Diffusion was proposed in by Xingqian Xu, Zhangyang Wang, Eric Zhang, Kai Wang, Humphrey Shi .

The abstract from the paper is:

The recent advances in diffusion models have set an impressive milestone in many generation tasks. Trending works such as DALL-E2, Imagen, and Stable Diffusion have attracted great interest in academia and industry. Despite the rapid landscape changes, recent new approaches focus on extensions and performance rather than capacity, thus requiring separate models for separate tasks. In this work, we expand the existing single-flow diffusion pipeline into a multi-flow network, dubbed Versatile Diffusion (VD), that handles text-to-image, image-to-text, image-variation, and text-variation in one unified model. Moreover, we generalize VD to a unified multi-flow multimodal diffusion framework with grouped layers, swappable streams, and other propositions that can process modalities beyond images and text. Through our experiments, we demonstrate that VD and its underlying framework have the following merits: a) VD handles all subtasks with competitive quality; b) VD initiates novel extensions and applications such as disentanglement of style and semantic, image-text dual-guided generation, etc.; c) Through these experiments and applications, VD provides more semantic insights of the generated outputs.

Tips

You can load the more memory intensive “all-in-one” that supports all the tasks or use the individual pipelines which are more memory efficient.

Pipeline

Supported tasks

all of the below

text-to-image

image variation

image-text dual guided generation

Make sure to check out the Schedulers to learn how to explore the tradeoff between scheduler speed and quality, and see the section to learn how to efficiently load the same components into multiple pipelines.

VersatileDiffusionPipeline

class diffusers.VersatileDiffusionPipeline

( tokenizer: CLIPTokenizerimage_feature_extractor: CLIPImageProcessortext_encoder: CLIPTextModelimage_encoder: CLIPVisionModelimage_unet: UNet2DConditionModeltext_unet: UNet2DConditionModelvae: AutoencoderKLscheduler: KarrasDiffusionSchedulers )

Parameters

  • tokenizer (CLIPTokenizer) — A CLIPTokenizer to tokenize text.

  • feature_extractor (CLIPImageProcessor) — A CLIPImageProcessor to extract features from generated images; used as inputs to the safety_checker.

Pipeline for text-to-image generation using Stable Diffusion.

dual_guided

Parameters

  • prompt (str or List[str]) — The prompt or prompts to guide image generation.

  • height (int, optional, defaults to self.image_unet.config.sample_size * self.vae_scale_factor) — The height in pixels of the generated image.

  • width (int, optional, defaults to self.image_unet.config.sample_size * self.vae_scale_factor) — The width in pixels of the generated image.

  • num_inference_steps (int, optional, defaults to 50) — The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference.

  • guidance_scale (float, optional, defaults to 7.5) — A higher guidance scale value encourages the model to generate images closely linked to the text prompt at the expense of lower image quality. Guidance scale is enabled when guidance_scale > 1.

  • negative_prompt (str or List[str], optional) — The prompt or prompts to guide what to not include in image generation. If not defined, you need to pass negative_prompt_embeds instead. Ignored when not using guidance (guidance_scale < 1).

  • num_images_per_prompt (int, optional, defaults to 1) — The number of images to generate per prompt.

  • latents (torch.FloatTensor, optional) — Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for image generation. Can be used to tweak the same generation with different prompts. If not provided, a latents tensor is generated by sampling using the supplied random generator.

  • output_type (str, optional, defaults to "pil") — The output format of the generated image. Choose between PIL.Image or np.array.

  • callback (Callable, optional) — A function that calls every callback_steps steps during inference. The function is called with the following arguments: callback(step: int, timestep: int, latents: torch.FloatTensor).

  • callback_steps (int, optional, defaults to 1) — The frequency at which the callback function is called. If not specified, the callback is called at every step.

Returns

The call function to the pipeline for generation.

Examples:

Copied

>>> from diffusers import VersatileDiffusionPipeline
>>> import torch
>>> import requests
>>> from io import BytesIO
>>> from PIL import Image

>>> # let's download an initial image
>>> url = "https://boincai.com/datasets/diffusers/images/resolve/main/benz.jpg"

>>> response = requests.get(url)
>>> image = Image.open(BytesIO(response.content)).convert("RGB")
>>> text = "a red car in the sun"

>>> pipe = VersatileDiffusionPipeline.from_pretrained(
...     "shi-labs/versatile-diffusion", torch_dtype=torch.float16
... )
>>> pipe = pipe.to("cuda")

>>> generator = torch.Generator(device="cuda").manual_seed(0)
>>> text_to_image_strength = 0.75

>>> image = pipe.dual_guided(
...     prompt=text, image=image, text_to_image_strength=text_to_image_strength, generator=generator
... ).images[0]
>>> image.save("./car_variation.png")

image_variation

Parameters

  • image (PIL.Image.Image, List[PIL.Image.Image] or torch.Tensor) — The image prompt or prompts to guide the image generation.

  • height (int, optional, defaults to self.image_unet.config.sample_size * self.vae_scale_factor) — The height in pixels of the generated image.

  • width (int, optional, defaults to self.image_unet.config.sample_size * self.vae_scale_factor) — The width in pixels of the generated image.

  • num_inference_steps (int, optional, defaults to 50) — The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference.

  • guidance_scale (float, optional, defaults to 7.5) — A higher guidance scale value encourages the model to generate images closely linked to the text prompt at the expense of lower image quality. Guidance scale is enabled when guidance_scale > 1.

  • negative_prompt (str or List[str], optional) — The prompt or prompts to guide what to not include in image generation. If not defined, you need to pass negative_prompt_embeds instead. Ignored when not using guidance (guidance_scale < 1).

  • num_images_per_prompt (int, optional, defaults to 1) — The number of images to generate per prompt.

  • latents (torch.FloatTensor, optional) — Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for image generation. Can be used to tweak the same generation with different prompts. If not provided, a latents tensor is generated by sampling using the supplied random generator.

  • output_type (str, optional, defaults to "pil") — The output format of the generated image. Choose between PIL.Image or np.array.

  • callback (Callable, optional) — A function that calls every callback_steps steps during inference. The function is called with the following arguments: callback(step: int, timestep: int, latents: torch.FloatTensor).

  • callback_steps (int, optional, defaults to 1) — The frequency at which the callback function is called. If not specified, the callback is called at every step.

Returns

The call function to the pipeline for generation.

Examples:

Copied

>>> from diffusers import VersatileDiffusionPipeline
>>> import torch
>>> import requests
>>> from io import BytesIO
>>> from PIL import Image

>>> # let's download an initial image
>>> url = "https://boincai.com/datasets/diffusers/images/resolve/main/benz.jpg"

>>> response = requests.get(url)
>>> image = Image.open(BytesIO(response.content)).convert("RGB")

>>> pipe = VersatileDiffusionPipeline.from_pretrained(
...     "shi-labs/versatile-diffusion", torch_dtype=torch.float16
... )
>>> pipe = pipe.to("cuda")

>>> generator = torch.Generator(device="cuda").manual_seed(0)
>>> image = pipe.image_variation(image, generator=generator).images[0]
>>> image.save("./car_variation.png")

text_to_image

Parameters

  • prompt (str or List[str]) — The prompt or prompts to guide image generation.

  • height (int, optional, defaults to self.image_unet.config.sample_size * self.vae_scale_factor) — The height in pixels of the generated image.

  • width (int, optional, defaults to self.image_unet.config.sample_size * self.vae_scale_factor) — The width in pixels of the generated image.

  • num_inference_steps (int, optional, defaults to 50) — The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference.

  • guidance_scale (float, optional, defaults to 7.5) — A higher guidance scale value encourages the model to generate images closely linked to the text prompt at the expense of lower image quality. Guidance scale is enabled when guidance_scale > 1.

  • negative_prompt (str or List[str], optional) — The prompt or prompts to guide what to not include in image generation. If not defined, you need to pass negative_prompt_embeds instead. Ignored when not using guidance (guidance_scale < 1).

  • num_images_per_prompt (int, optional, defaults to 1) — The number of images to generate per prompt.

  • latents (torch.FloatTensor, optional) — Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for image generation. Can be used to tweak the same generation with different prompts. If not provided, a latents tensor is generated by sampling using the supplied random generator.

  • output_type (str, optional, defaults to "pil") — The output format of the generated image. Choose between PIL.Image or np.array.

  • callback (Callable, optional) — A function that calls every callback_steps steps during inference. The function is called with the following arguments: callback(step: int, timestep: int, latents: torch.FloatTensor).

  • callback_steps (int, optional, defaults to 1) — The frequency at which the callback function is called. If not specified, the callback is called at every step.

Returns

The call function to the pipeline for generation.

Examples:

Copied

>>> from diffusers import VersatileDiffusionPipeline
>>> import torch

>>> pipe = VersatileDiffusionPipeline.from_pretrained(
...     "shi-labs/versatile-diffusion", torch_dtype=torch.float16
... )
>>> pipe = pipe.to("cuda")

>>> generator = torch.Generator(device="cuda").manual_seed(0)
>>> image = pipe.text_to_image("an astronaut riding on a horse on mars", generator=generator).images[0]
>>> image.save("./astronaut.png")

VersatileDiffusionTextToImagePipeline

class diffusers.VersatileDiffusionTextToImagePipeline

( tokenizer: CLIPTokenizertext_encoder: CLIPTextModelWithProjectionimage_unet: UNet2DConditionModeltext_unet: UNetFlatConditionModelvae: AutoencoderKLscheduler: KarrasDiffusionSchedulers )

Parameters

  • bert (LDMBertModel) — Text-encoder model based on BERT.

  • tokenizer (BertTokenizer) — A BertTokenizer to tokenize text.

Pipeline for text-to-image generation using Versatile Diffusion.

__call__

Parameters

  • prompt (str or List[str]) — The prompt or prompts to guide image generation.

  • height (int, optional, defaults to self.image_unet.config.sample_size * self.vae_scale_factor) — The height in pixels of the generated image.

  • width (int, optional, defaults to self.image_unet.config.sample_size * self.vae_scale_factor) — The width in pixels of the generated image.

  • num_inference_steps (int, optional, defaults to 50) — The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference.

  • guidance_scale (float, optional, defaults to 7.5) — A higher guidance scale value encourages the model to generate images closely linked to the text prompt at the expense of lower image quality. Guidance scale is enabled when guidance_scale > 1.

  • negative_prompt (str or List[str], optional) — The prompt or prompts to guide what to not include in image generation. If not defined, you need to pass negative_prompt_embeds instead. Ignored when not using guidance (guidance_scale < 1).

  • num_images_per_prompt (int, optional, defaults to 1) — The number of images to generate per prompt.

  • latents (torch.FloatTensor, optional) — Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for image generation. Can be used to tweak the same generation with different prompts. If not provided, a latents tensor is generated by sampling using the supplied random generator.

  • output_type (str, optional, defaults to "pil") — The output format of the generated image. Choose between PIL.Image or np.array.

  • callback (Callable, optional) — A function that calls every callback_steps steps during inference. The function is called with the following arguments: callback(step: int, timestep: int, latents: torch.FloatTensor).

  • callback_steps (int, optional, defaults to 1) — The frequency at which the callback function is called. If not specified, the callback is called at every step.

Returns

The call function to the pipeline for generation.

Examples:

Copied

>>> from diffusers import VersatileDiffusionTextToImagePipeline
>>> import torch

>>> pipe = VersatileDiffusionTextToImagePipeline.from_pretrained(
...     "shi-labs/versatile-diffusion", torch_dtype=torch.float16
... )
>>> pipe.remove_unused_weights()
>>> pipe = pipe.to("cuda")

>>> generator = torch.Generator(device="cuda").manual_seed(0)
>>> image = pipe("an astronaut riding on a horse on mars", generator=generator).images[0]
>>> image.save("./astronaut.png")

VersatileDiffusionImageVariationPipeline

class diffusers.VersatileDiffusionImageVariationPipeline

( image_feature_extractor: CLIPImageProcessorimage_encoder: CLIPVisionModelWithProjectionimage_unet: UNet2DConditionModelvae: AutoencoderKLscheduler: KarrasDiffusionSchedulers )

Parameters

  • bert (LDMBertModel) — Text-encoder model based on BERT.

  • tokenizer (BertTokenizer) — A BertTokenizer to tokenize text.

Pipeline for image variation using Versatile Diffusion.

__call__

Parameters

  • image (PIL.Image.Image, List[PIL.Image.Image] or torch.Tensor) — The image prompt or prompts to guide the image generation.

  • height (int, optional, defaults to self.image_unet.config.sample_size * self.vae_scale_factor) — The height in pixels of the generated image.

  • width (int, optional, defaults to self.image_unet.config.sample_size * self.vae_scale_factor) — The width in pixels of the generated image.

  • num_inference_steps (int, optional, defaults to 50) — The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference.

  • guidance_scale (float, optional, defaults to 7.5) — A higher guidance scale value encourages the model to generate images closely linked to the text prompt at the expense of lower image quality. Guidance scale is enabled when guidance_scale > 1.

  • negative_prompt (str or List[str], optional) — The prompt or prompts to guide what to not include in image generation. If not defined, you need to pass negative_prompt_embeds instead. Ignored when not using guidance (guidance_scale < 1).

  • num_images_per_prompt (int, optional, defaults to 1) — The number of images to generate per prompt.

  • latents (torch.FloatTensor, optional) — Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for image generation. Can be used to tweak the same generation with different prompts. If not provided, a latents tensor is generated by sampling using the supplied random generator.

  • output_type (str, optional, defaults to "pil") — The output format of the generated image. Choose between PIL.Image or np.array.

  • callback (Callable, optional) — A function that calls every callback_steps steps during inference. The function is called with the following arguments: callback(step: int, timestep: int, latents: torch.FloatTensor).

  • callback_steps (int, optional, defaults to 1) — The frequency at which the callback function is called. If not specified, the callback is called at every step.

Returns

The call function to the pipeline for generation.

Examples:

Copied

>>> from diffusers import VersatileDiffusionImageVariationPipeline
>>> import torch
>>> import requests
>>> from io import BytesIO
>>> from PIL import Image

>>> # let's download an initial image
>>> url = "https://boincai.com/datasets/diffusers/images/resolve/main/benz.jpg"

>>> response = requests.get(url)
>>> image = Image.open(BytesIO(response.content)).convert("RGB")

>>> pipe = VersatileDiffusionImageVariationPipeline.from_pretrained(
...     "shi-labs/versatile-diffusion", torch_dtype=torch.float16
... )
>>> pipe = pipe.to("cuda")

>>> generator = torch.Generator(device="cuda").manual_seed(0)
>>> image = pipe(image, generator=generator).images[0]
>>> image.save("./car_variation.png")

VersatileDiffusionDualGuidedPipeline

class diffusers.VersatileDiffusionDualGuidedPipeline

( tokenizer: CLIPTokenizerimage_feature_extractor: CLIPImageProcessortext_encoder: CLIPTextModelWithProjectionimage_encoder: CLIPVisionModelWithProjectionimage_unet: UNet2DConditionModeltext_unet: UNetFlatConditionModelvae: AutoencoderKLscheduler: KarrasDiffusionSchedulers )

Parameters

  • bert (LDMBertModel) — Text-encoder model based on BERT.

  • tokenizer (BertTokenizer) — A BertTokenizer to tokenize text.

Pipeline for image-text dual-guided generation using Versatile Diffusion.

__call__

Parameters

  • prompt (str or List[str]) — The prompt or prompts to guide image generation.

  • height (int, optional, defaults to self.image_unet.config.sample_size * self.vae_scale_factor) — The height in pixels of the generated image.

  • width (int, optional, defaults to self.image_unet.config.sample_size * self.vae_scale_factor) — The width in pixels of the generated image.

  • num_inference_steps (int, optional, defaults to 50) — The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference.

  • guidance_scale (float, optional, defaults to 7.5) — A higher guidance scale value encourages the model to generate images closely linked to the text prompt at the expense of lower image quality. Guidance scale is enabled when guidance_scale > 1.

  • negative_prompt (str or List[str], optional) — The prompt or prompts to guide what to not include in image generation. If not defined, you need to pass negative_prompt_embeds instead. Ignored when not using guidance (guidance_scale < 1).

  • num_images_per_prompt (int, optional, defaults to 1) — The number of images to generate per prompt.

  • latents (torch.FloatTensor, optional) — Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for image generation. Can be used to tweak the same generation with different prompts. If not provided, a latents tensor is generated by sampling using the supplied random generator.

  • output_type (str, optional, defaults to "pil") — The output format of the generated image. Choose between PIL.Image or np.array.

  • callback (Callable, optional) — A function that calls every callback_steps steps during inference. The function is called with the following arguments: callback(step: int, timestep: int, latents: torch.FloatTensor).

  • callback_steps (int, optional, defaults to 1) — The frequency at which the callback function is called. If not specified, the callback is called at every step.

Returns

The call function to the pipeline for generation.

Examples:

Copied

>>> from diffusers import VersatileDiffusionDualGuidedPipeline
>>> import torch
>>> import requests
>>> from io import BytesIO
>>> from PIL import Image

>>> # let's download an initial image
>>> url = "https://boincai.com/datasets/diffusers/images/resolve/main/benz.jpg"

>>> response = requests.get(url)
>>> image = Image.open(BytesIO(response.content)).convert("RGB")
>>> text = "a red car in the sun"

>>> pipe = VersatileDiffusionDualGuidedPipeline.from_pretrained(
...     "shi-labs/versatile-diffusion", torch_dtype=torch.float16
... )
>>> pipe.remove_unused_weights()
>>> pipe = pipe.to("cuda")

>>> generator = torch.Generator(device="cuda").manual_seed(0)
>>> text_to_image_strength = 0.75

>>> image = pipe(
...     prompt=text, image=image, text_to_image_strength=text_to_image_strength, generator=generator
... ).images[0]
>>> image.save("./car_variation.png")

vae () — Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.

text_encoder (CLIPTextModel) — Frozen text-encoder ().

unet () — A UNet2DConditionModel to denoise the encoded image latents.

scheduler () — A scheduler to be used in combination with unet to denoise the encoded image latents. Can be one of , , or .

safety_checker (StableDiffusionSafetyChecker) — Classification module that estimates whether generated images could be considered offensive or harmful. Please refer to the for more details about a model’s potential harms.

This model inherits from . Check the superclass documentation for the generic methods implemented for all pipelines (downloading, saving, running on a particular device, etc.).

( prompt: typing.Union[PIL.Image.Image, typing.List[PIL.Image.Image]]image: typing.Union[str, typing.List[str]]text_to_image_strength: float = 0.5height: typing.Optional[int] = Nonewidth: typing.Optional[int] = Nonenum_inference_steps: int = 50guidance_scale: float = 7.5num_images_per_prompt: typing.Optional[int] = 1eta: float = 0.0generator: typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = Nonelatents: typing.Optional[torch.FloatTensor] = Noneoutput_type: typing.Optional[str] = 'pil'return_dict: bool = Truecallback: typing.Union[typing.Callable[[int, int, torch.FloatTensor], NoneType], NoneType] = Nonecallback_steps: int = 1 ) → or tuple

eta (float, optional, defaults to 0.0) — Corresponds to parameter eta (η) from the paper. Only applies to the , and is ignored in other schedulers.

generator (torch.Generator or List[torch.Generator], optional) — A to make generation deterministic.

return_dict (bool, optional, defaults to True) — Whether or not to return a instead of a plain tuple.

or tuple

If return_dict is True, is returned, otherwise a tuple is returned where the first element is a list with the generated images.

( image: typing.Union[torch.FloatTensor, PIL.Image.Image]height: typing.Optional[int] = Nonewidth: typing.Optional[int] = Nonenum_inference_steps: int = 50guidance_scale: float = 7.5negative_prompt: typing.Union[str, typing.List[str], NoneType] = Nonenum_images_per_prompt: typing.Optional[int] = 1eta: float = 0.0generator: typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = Nonelatents: typing.Optional[torch.FloatTensor] = Noneoutput_type: typing.Optional[str] = 'pil'return_dict: bool = Truecallback: typing.Union[typing.Callable[[int, int, torch.FloatTensor], NoneType], NoneType] = Nonecallback_steps: int = 1 ) → or tuple

eta (float, optional, defaults to 0.0) — Corresponds to parameter eta (η) from the paper. Only applies to the , and is ignored in other schedulers.

generator (torch.Generator, optional) — A to make generation deterministic.

return_dict (bool, optional, defaults to True) — Whether or not to return a instead of a plain tuple.

or tuple

If return_dict is True, is returned, otherwise a tuple is returned where the first element is a list with the generated images and the second element is a list of bools indicating whether the corresponding generated image contains “not-safe-for-work” (nsfw) content.

( prompt: typing.Union[str, typing.List[str]]height: typing.Optional[int] = Nonewidth: typing.Optional[int] = Nonenum_inference_steps: int = 50guidance_scale: float = 7.5negative_prompt: typing.Union[str, typing.List[str], NoneType] = Nonenum_images_per_prompt: typing.Optional[int] = 1eta: float = 0.0generator: typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = Nonelatents: typing.Optional[torch.FloatTensor] = Noneoutput_type: typing.Optional[str] = 'pil'return_dict: bool = Truecallback: typing.Union[typing.Callable[[int, int, torch.FloatTensor], NoneType], NoneType] = Nonecallback_steps: int = 1 ) → or tuple

eta (float, optional, defaults to 0.0) — Corresponds to parameter eta (η) from the paper. Only applies to the , and is ignored in other schedulers.

generator (torch.Generator, optional) — A to make generation deterministic.

return_dict (bool, optional, defaults to True) — Whether or not to return a instead of a plain tuple.

or tuple

If return_dict is True, is returned, otherwise a tuple is returned where the first element is a list with the generated images and the second element is a list of bools indicating whether the corresponding generated image contains “not-safe-for-work” (nsfw) content.

vqvae () — Vector-quantized (VQ) model to encode and decode images to and from latent representations.

unet () — A UNet2DConditionModel to denoise the encoded image latents.

scheduler () — A scheduler to be used in combination with unet to denoise the encoded image latents. Can be one of , , or .

This model inherits from . Check the superclass documentation for the generic methods implemented for all pipelines (downloading, saving, running on a particular device, etc.).

( prompt: typing.Union[str, typing.List[str]]height: typing.Optional[int] = Nonewidth: typing.Optional[int] = Nonenum_inference_steps: int = 50guidance_scale: float = 7.5negative_prompt: typing.Union[str, typing.List[str], NoneType] = Nonenum_images_per_prompt: typing.Optional[int] = 1eta: float = 0.0generator: typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = Nonelatents: typing.Optional[torch.FloatTensor] = Noneoutput_type: typing.Optional[str] = 'pil'return_dict: bool = Truecallback: typing.Union[typing.Callable[[int, int, torch.FloatTensor], NoneType], NoneType] = Nonecallback_steps: int = 1**kwargs ) → or tuple

eta (float, optional, defaults to 0.0) — Corresponds to parameter eta (η) from the paper. Only applies to the , and is ignored in other schedulers.

generator (torch.Generator, optional) — A to make generation deterministic.

return_dict (bool, optional, defaults to True) — Whether or not to return a instead of a plain tuple.

or tuple

If return_dict is True, is returned, otherwise a tuple is returned where the first element is a list with the generated images.

vqvae () — Vector-quantized (VQ) model to encode and decode images to and from latent representations.

unet () — A UNet2DConditionModel to denoise the encoded image latents.

scheduler () — A scheduler to be used in combination with unet to denoise the encoded image latents. Can be one of , , or .

This model inherits from . Check the superclass documentation for the generic methods implemented for all pipelines (downloading, saving, running on a particular device, etc.).

( image: typing.Union[PIL.Image.Image, typing.List[PIL.Image.Image], torch.Tensor]height: typing.Optional[int] = Nonewidth: typing.Optional[int] = Nonenum_inference_steps: int = 50guidance_scale: float = 7.5negative_prompt: typing.Union[str, typing.List[str], NoneType] = Nonenum_images_per_prompt: typing.Optional[int] = 1eta: float = 0.0generator: typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = Nonelatents: typing.Optional[torch.FloatTensor] = Noneoutput_type: typing.Optional[str] = 'pil'return_dict: bool = Truecallback: typing.Union[typing.Callable[[int, int, torch.FloatTensor], NoneType], NoneType] = Nonecallback_steps: int = 1**kwargs ) → or tuple

eta (float, optional, defaults to 0.0) — Corresponds to parameter eta (η) from the paper. Only applies to the , and is ignored in other schedulers.

generator (torch.Generator, optional) — A to make generation deterministic.

return_dict (bool, optional, defaults to True) — Whether or not to return a instead of a plain tuple.

or tuple

If return_dict is True, is returned, otherwise a tuple is returned where the first element is a list with the generated images.

vqvae () — Vector-quantized (VQ) model to encode and decode images to and from latent representations.

unet () — A UNet2DConditionModel to denoise the encoded image latents.

scheduler () — A scheduler to be used in combination with unet to denoise the encoded image latents. Can be one of , , or .

This model inherits from . Check the superclass documentation for the generic methods implemented for all pipelines (downloading, saving, running on a particular device, etc.).

( prompt: typing.Union[PIL.Image.Image, typing.List[PIL.Image.Image]]image: typing.Union[str, typing.List[str]]text_to_image_strength: float = 0.5height: typing.Optional[int] = Nonewidth: typing.Optional[int] = Nonenum_inference_steps: int = 50guidance_scale: float = 7.5num_images_per_prompt: typing.Optional[int] = 1eta: float = 0.0generator: typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = Nonelatents: typing.Optional[torch.FloatTensor] = Noneoutput_type: typing.Optional[str] = 'pil'return_dict: bool = Truecallback: typing.Union[typing.Callable[[int, int, torch.FloatTensor], NoneType], NoneType] = Nonecallback_steps: int = 1**kwargs ) → or tuple

eta (float, optional, defaults to 0.0) — Corresponds to parameter eta (η) from the paper. Only applies to the , and is ignored in other schedulers.

generator (torch.Generator or List[torch.Generator], optional) — A to make generation deterministic.

return_dict (bool, optional, defaults to True) — Whether or not to return a instead of a plain tuple.

or tuple

If return_dict is True, is returned, otherwise a tuple is returned where the first element is a list with the generated images.

🌍
🌍
Versatile Diffusion: Text, Images and Variations All in One Diffusion Model
VersatileDiffusionPipeline
guide
reuse components across pipelines
<source>
AutoencoderKL
clip-vit-large-patch14
UNet2DConditionModel
SchedulerMixin
DDIMScheduler
LMSDiscreteScheduler
PNDMScheduler
model card
DiffusionPipeline
<source>
ImagePipelineOutput
DDIM
DDIMScheduler
torch.Generator
StableDiffusionPipelineOutput
ImagePipelineOutput
ImagePipelineOutput
<source>
StableDiffusionPipelineOutput
DDIM
DDIMScheduler
torch.Generator
StableDiffusionPipelineOutput
StableDiffusionPipelineOutput
StableDiffusionPipelineOutput
<source>
StableDiffusionPipelineOutput
DDIM
DDIMScheduler
torch.Generator
StableDiffusionPipelineOutput
StableDiffusionPipelineOutput
StableDiffusionPipelineOutput
<source>
VQModel
UNet2DConditionModel
SchedulerMixin
DDIMScheduler
LMSDiscreteScheduler
PNDMScheduler
DiffusionPipeline
<source>
StableDiffusionPipelineOutput
DDIM
DDIMScheduler
torch.Generator
StableDiffusionPipelineOutput
StableDiffusionPipelineOutput
StableDiffusionPipelineOutput
<source>
VQModel
UNet2DConditionModel
SchedulerMixin
DDIMScheduler
LMSDiscreteScheduler
PNDMScheduler
DiffusionPipeline
<source>
StableDiffusionPipelineOutput
DDIM
DDIMScheduler
torch.Generator
StableDiffusionPipelineOutput
StableDiffusionPipelineOutput
StableDiffusionPipelineOutput
<source>
VQModel
UNet2DConditionModel
SchedulerMixin
DDIMScheduler
LMSDiscreteScheduler
PNDMScheduler
DiffusionPipeline
<source>
ImagePipelineOutput
DDIM
DDIMScheduler
torch.Generator
ImagePipelineOutput
ImagePipelineOutput
ImagePipelineOutput
VersatileDiffusionPipeline
VersatileDiffusionTextToImagePipeline
VersatileDiffusionImageVariationPipeline
VersatileDiffusionDualGuidedPipeline