text
stringlengths
0
5.54k
cumulative result (omitting logarithms):
_0_cumulative(x_t | x_0 = C_0) ... q_n_cumulative(x_t | x_0 = C_0)
. . .
. . .
. . .
q_0_cumulative(x_t | x_0 = C_{k-1\}) ... q_n_cumulative(x_t | x_0 = C_{k-1\})`}
wrap={false}
/>
Calculates the log probabilities of the rows from the (cumulative or non-cumulative) transition matrix for each
latent pixel in x_t. q_posterior < source > ( log_p_x_0 x_t t ) → torch.FloatTensor of shape (batch size, num classes, num latent pixels) Parameters log_p_x_0 (torch.FloatTensor of shape (batch size, num classes - 1, num latent pixels)) —
The log probabilities for the predicted classes of the initial latent pixels. Does not include a
prediction for the masked class as the initial unnoised image cannot be masked. x_t (torch.LongTensor of shape (batch size, num latent pixels)) —
The classes of each latent pixel at time t. t (torch.Long) —
The timestep that determines which transition matrix is used. Returns
torch.FloatTensor of shape (batch size, num classes, num latent pixels)
The log probabilities for the predicted classes of the image at timestep t-1.
Calculates the log probabilities for the predicted classes of the image at timestep t-1: Copied p(x_{t-1} | x_t) = sum( q(x_t | x_{t-1}) * q(x_{t-1} | x_0) * p(x_0) / q(x_t | x_0) ) set_timesteps < source > ( num_inference_steps: int device: Union = 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 and diffusion process parameters (alpha, beta, gamma) should be moved
to. Sets the discrete timesteps used for the diffusion chain (to be run before inference). step < source > ( model_output: FloatTensor timestep: torch.int64 sample: LongTensor generator: Optional = None return_dict: bool = True ) → VQDiffusionSchedulerOutput or tuple Parameters t (torch.long) —
The timestep that determines which transition matrices are used. x_t (torch.LongTensor of shape (batch size, num latent pixels)) —
The classes of each latent pixel at time t. generator (torch.Generator, or None) —
A random number generator for the noise applied to p(x_{t-1} | x_t) before it is sampled from. return_dict (bool, optional, defaults to True) —
Whether or not to return a VQDiffusionSchedulerOutput or
tuple. Returns
VQDiffusionSchedulerOutput or tuple
If return_dict is True, VQDiffusionSchedulerOutput is
returned, otherwise a tuple is returned where the first element is the sample tensor.
Predict the sample from the previous timestep by the reverse transition distribution. See
q_posterior() for more details about how the distribution is computer. VQDiffusionSchedulerOutput class diffusers.schedulers.scheduling_vq_diffusion.VQDiffusionSchedulerOutput < source > ( prev_sample: LongTensor ) Parameters prev_sample (torch.LongTensor of shape (batch size, num latent pixels)) —
Computed sample x_{t-1} of previous timestep. prev_sample should be used as next model input in the
denoising loop. Output class for the scheduler’s step function output.
Overview The APIs in this section are more experimental and prone to breaking changes. Most of them are used internally for development, but they may also be useful to you if you’re interested in building a diffusion model with some custom parts or if you’re interested in some of our helper utilities for working with �...
Variance exploding, stochastic sampling from Karras et. al
Overview
Original paper can be found here.
KarrasVeScheduler
class diffusers.KarrasVeScheduler
<
source
>
(
sigma_min: float = 0.02
sigma_max: float = 100
s_noise: float = 1.007
s_churn: float = 80
s_min: float = 0.05
s_max: float = 50
)
Parameters
sigma_min (float) — minimum noise magnitude
sigma_max (float) — maximum noise magnitude
s_noise (float) — the amount of additional noise to counteract loss of detail during sampling.
A reasonable range is [1.000, 1.011].
s_churn (float) — the parameter controlling the overall amount of stochasticity.
A reasonable range is [0, 100].
s_min (float) — the start value of the sigma range where we add noise (enable stochasticity).
A reasonable range is [0, 10].
s_max (float) — the end value of the sigma range where we add noise.
A reasonable range is [0.2, 80].
Stochastic sampling from Karras et al. [1] tailored to the Variance-Expanding (VE) models [2]. Use Algorithm 2 and
the VE column of Table 1 from [1] for reference.
[1] Karras, Tero, et al. “Elucidating the Design Space of Diffusion-Based Generative Models.”
https://arxiv.org/abs/2206.00364 [2] Song, Yang, et al. “Score-based generative modeling through stochastic
differential equations.” https://arxiv.org/abs/2011.13456
~ConfigMixin takes care of storing all config attributes that are passed in the scheduler’s __init__
function, such as num_train_timesteps. They can be accessed via scheduler.config.num_train_timesteps.
SchedulerMixin provides general loading and saving functionality via the SchedulerMixin.save_pretrained() and
from_pretrained() functions.
For more details on the parameters, see the original paper’s Appendix E.: “Elucidating the Design Space of
Diffusion-Based Generative Models.” https://arxiv.org/abs/2206.00364. 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.
add_noise_to_input