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
  • ScoreSdeVeScheduler
  • ScoreSdeVeScheduler
  • SdeVeOutput
  1. API
  2. SCHEDULERS

ScoreSdeVeScheduler

PreviousRePaintSchedulerNextScoreSdeVpScheduler

Last updated 1 year ago

ScoreSdeVeScheduler

ScoreSdeVeScheduler is a variance exploding stochastic differential equation (SDE) scheduler. It was introduced in the paper by Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon, Ben Poole.

The abstract from the paper is:

Creating noise from data is easy; creating data from noise is generative modeling. We present a stochastic differential equation (SDE) that smoothly transforms a complex data distribution to a known prior distribution by slowly injecting noise, and a corresponding reverse-time SDE that transforms the prior distribution back into the data distribution by slowly removing the noise. Crucially, the reverse-time SDE depends only on the time-dependent gradient field (\aka, score) of the perturbed data distribution. By leveraging advances in score-based generative modeling, we can accurately estimate these scores with neural networks, and use numerical SDE solvers to generate samples. We show that this framework encapsulates previous approaches in score-based generative modeling and diffusion probabilistic modeling, allowing for new sampling procedures and new modeling capabilities. In particular, we introduce a predictor-corrector framework to correct errors in the evolution of the discretized reverse-time SDE. We also derive an equivalent neural ODE that samples from the same distribution as the SDE, but additionally enables exact likelihood computation, and improved sampling efficiency. In addition, we provide a new way to solve inverse problems with score-based models, as demonstrated with experiments on class-conditional generation, image inpainting, and colorization. Combined with multiple architectural improvements, we achieve record-breaking performance for unconditional image generation on CIFAR-10 with an Inception score of 9.89 and FID of 2.20, a competitive likelihood of 2.99 bits/dim, and demonstrate high fidelity generation of 1024 x 1024 images for the first time from a score-based generative model.

ScoreSdeVeScheduler

class diffusers.ScoreSdeVeScheduler

( num_train_timesteps: int = 2000snr: float = 0.15sigma_min: float = 0.01sigma_max: float = 1348.0sampling_eps: float = 1e-05correct_steps: int = 1 )

Parameters

  • num_train_timesteps (int, defaults to 1000) β€” The number of diffusion steps to train the model.

  • snr (float, defaults to 0.15) β€” A coefficient weighting the step from the model_output sample (from the network) to the random noise.

  • sigma_min (float, defaults to 0.01) β€” The initial noise scale for the sigma sequence in the sampling procedure. The minimum sigma should mirror the distribution of the data.

  • sigma_max (float, defaults to 1348.0) β€” The maximum value used for the range of continuous timesteps passed into the model.

  • sampling_eps (float, defaults to 1e-5) β€” The end value of sampling where timesteps decrease progressively from 1 to epsilon.

  • correct_steps (int, defaults to 1) β€” The number of correction steps performed on a produced sample.

ScoreSdeVeScheduler is a variance exploding stochastic differential equation (SDE) scheduler.

scale_model_input

( sample: FloatTensortimestep: typing.Optional[int] = None ) β†’ torch.FloatTensor

Parameters

  • sample (torch.FloatTensor) β€” The input sample.

  • timestep (int, optional) β€” The current timestep in the diffusion chain.

Returns

torch.FloatTensor

A scaled input sample.

Ensures interchangeability with schedulers that need to scale the denoising model input depending on the current timestep.

set_sigmas

( num_inference_steps: intsigma_min: float = Nonesigma_max: float = Nonesampling_eps: float = None )

Parameters

  • num_inference_steps (int) β€” The number of diffusion steps used when generating samples with a pre-trained model.

  • sigma_min (float, optional) β€” The initial noise scale value (overrides value given during scheduler instantiation).

  • sigma_max (float, optional) β€” The final noise scale value (overrides value given during scheduler instantiation).

  • sampling_eps (float, optional) β€” The final timestep value (overrides value given during scheduler instantiation).

Sets the noise scales used for the diffusion chain (to be run before inference). The sigmas control the weight of the drift and diffusion components of the sample update.

set_timesteps

( num_inference_steps: intsampling_eps: float = Nonedevice: typing.Union[str, torch.device] = None )

Parameters

  • num_inference_steps (int) β€” The number of diffusion steps used when generating samples with a pre-trained model.

  • sampling_eps (float, optional) β€” The final timestep value (overrides value given during scheduler instantiation).

  • device (str or torch.device, optional) β€” The device to which the timesteps should be moved to. If None, the timesteps are not moved.

Sets the continuous timesteps used for the diffusion chain (to be run before inference).

step_correct

Parameters

  • model_output (torch.FloatTensor) β€” The direct output from learned diffusion model.

  • sample (torch.FloatTensor) β€” A current instance of a sample created by the diffusion process.

  • generator (torch.Generator, optional) β€” A random number generator.

Returns

Correct the predicted sample based on the model_output of the network. This is often run repeatedly after making the prediction for the previous timestep.

step_pred

Parameters

  • model_output (torch.FloatTensor) β€” The direct output from learned diffusion model.

  • timestep (int) β€” The current discrete timestep in the diffusion chain.

  • sample (torch.FloatTensor) β€” A current instance of a sample created by the diffusion process.

  • generator (torch.Generator, optional) β€” A random number generator.

Returns

Predict the sample from the previous timestep by reversing the SDE. This function propagates the diffusion process from the learned model outputs (most often the predicted noise).

SdeVeOutput

class diffusers.schedulers.scheduling_sde_ve.SdeVeOutput

( prev_sample: FloatTensorprev_sample_mean: FloatTensor )

Parameters

  • prev_sample (torch.FloatTensor of shape (batch_size, num_channels, height, width) for images) β€” Computed sample (x_{t-1}) of previous timestep. prev_sample should be used as next model input in the denoising loop.

  • prev_sample_mean (torch.FloatTensor of shape (batch_size, num_channels, height, width) for images) β€” Mean averaged prev_sample over previous timesteps.

Output class for the scheduler’s step function output.

This model inherits from and . Check the superclass documentation for the generic methods the library implements for all schedulers such as loading and saving.

( model_output: FloatTensorsample: FloatTensorgenerator: typing.Optional[torch._C.Generator] = Nonereturn_dict: bool = True ) β†’ or tuple

return_dict (bool, optional, defaults to True) β€” Whether or not to return a or tuple.

or tuple

If return_dict is True, is returned, otherwise a tuple is returned where the first element is the sample tensor.

( model_output: FloatTensortimestep: intsample: FloatTensorgenerator: typing.Optional[torch._C.Generator] = Nonereturn_dict: bool = True ) β†’ or tuple

return_dict (bool, optional, defaults to True) β€” Whether or not to return a or tuple.

or tuple

If return_dict is True, is returned, otherwise a tuple is returned where the first element is the sample tensor.

🌍
🌍
Score-Based Generative Modeling through Stochastic Differential Equations
<source>
SchedulerMixin
ConfigMixin
<source>
<source>
<source>
<source>
SdeVeOutput
SdeVeOutput
SdeVeOutput
SdeVeOutput
<source>
SdeVeOutput
SdeVeOutput
SdeVeOutput
SdeVeOutput
<source>