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
  • KarrasVeScheduler
  • KarrasVeScheduler
  • KarrasVeOutput
  1. API
  2. SCHEDULERS

KarrasVeScheduler

PreviousIPNDMSchedulerNextKDPM2AncestralDiscreteScheduler

Last updated 1 year ago

KarrasVeScheduler

KarrasVeScheduler is a stochastic sampler tailored o variance-expanding (VE) models. It is based on the and papers.

KarrasVeScheduler

class diffusers.KarrasVeScheduler

( sigma_min: float = 0.02sigma_max: float = 100s_noise: float = 1.007s_churn: float = 80s_min: float = 0.05s_max: float = 50 )

Parameters

  • sigma_min (float, defaults to 0.02) β€” The minimum noise magnitude.

  • sigma_max (float, defaults to 100) β€” The maximum noise magnitude.

  • s_noise (float, defaults to 1.007) β€” The amount of additional noise to counteract loss of detail during sampling. A reasonable range is [1.000, 1.011].

  • s_churn (float, defaults to 80) β€” The parameter controlling the overall amount of stochasticity. A reasonable range is [0, 100].

  • s_min (float, defaults to 0.05) β€” The start value of the sigma range to add noise (enable stochasticity). A reasonable range is [0, 10].

  • s_max (float, defaults to 50) β€” The end value of the sigma range to add noise. A reasonable range is [0.2, 80].

A stochastic scheduler tailored to variance-expanding models.

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

add_noise_to_input

( sample: FloatTensorsigma: floatgenerator: typing.Optional[torch._C.Generator] = None )

Parameters

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

  • sigma (float) β€”

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

Explicit Langevin-like β€œchurn” step of adding noise to the sample according to a gamma_i β‰₯ 0 to reach a higher noise level sigma_hat = sigma_i + gamma_i*sigma_i.

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_timesteps

( num_inference_steps: intdevice: 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.

  • 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 discrete timesteps used for the diffusion chain (to be run before inference).

step

( model_output: FloatTensorsigma_hat: floatsigma_prev: floatsample_hat: FloatTensorreturn_dict: bool = True ) β†’ ~schedulers.scheduling_karras_ve.KarrasVESchedulerOutput or tuple

Parameters

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

  • sigma_hat (float) β€”

  • sigma_prev (float) β€”

  • sample_hat (torch.FloatTensor) β€”

  • return_dict (bool, optional, defaults to True) β€” Whether or not to return a ~schedulers.scheduling_karras_ve.KarrasVESchedulerOutput or tuple.

Returns

~schedulers.scheduling_karras_ve.KarrasVESchedulerOutput or tuple

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

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).

step_correct

( model_output: FloatTensorsigma_hat: floatsigma_prev: floatsample_hat: FloatTensorsample_prev: FloatTensorderivative: FloatTensorreturn_dict: bool = True ) β†’ prev_sample (TODO)

Parameters

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

  • sigma_hat (float) β€” TODO

  • sigma_prev (float) β€” TODO

  • sample_hat (torch.FloatTensor) β€” TODO

  • sample_prev (torch.FloatTensor) β€” TODO

  • derivative (torch.FloatTensor) β€” TODO

Returns

prev_sample (TODO)

updated sample in the diffusion chain. derivative (TODO): TODO

Corrects the predicted sample based on the model_output of the network.

KarrasVeOutput

class diffusers.schedulers.scheduling_karras_ve.KarrasVeOutput

( prev_sample: FloatTensorderivative: FloatTensorpred_original_sample: typing.Optional[torch.FloatTensor] = None )

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.

  • derivative (torch.FloatTensor of shape (batch_size, num_channels, height, width) for images) β€” Derivative of predicted original image sample (x_0).

  • pred_original_sample (torch.FloatTensor of shape (batch_size, num_channels, height, width) for images) β€” The predicted denoised sample (x_{0}) based on the model output from the current timestep. pred_original_sample can be used to preview progress or for guidance.

Output class for the scheduler’s step function output.

For more details on the parameters, see . The grid search values used to find the optimal {s_noise, s_churn, s_min, s_max} for a specific model are described in Table 5 of the paper.

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

🌍
🌍
Elucidating the Design Space of Diffusion-Based Generative Models
Score-based generative modeling through stochastic differential equations
<source>
SchedulerMixin
ConfigMixin
Appendix E
<source>
<source>
<source>
<source>
<source>
DDPMSchedulerOutput
<source>