autocast.processors.diffusion#
- class DiffusionProcessor(backbone, schedule, denoiser_type='karras', learning_rate=0.0001, n_steps_output=4, n_channels_out=1, sampler_steps=50, sampler='euler')[source]#
Bases:
ProcessorDiffusion Processor.
- Parameters:
- forward(x, global_cond=None)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- loss(batch)[source]#
Training step with diffusion loss.
Sample random time steps and compute loss between denoised output and the clean data.
- Parameters:
batch (EncodedBatch)
- Return type:
- sample(x_t, cond, num_steps=100, sampler='euler', eta=0.0, return_trajectory=False, silent=True, **sampler_kwargs)[source]#
Generate samples via reverse diffusion using Azula’s samplers.
- Parameters:
x_t (Tensor) – Starting noise (B, T, C, W, H)
cond (Tensor) – Conditioning input (B, T_cond, C_cond, W, H)
num_steps (int) – Number of denoising steps
sampler (str) – Type of sampler to use: - ‘euler’: Euler ODE solver (fast, deterministic) - ‘heun’: Heun’s method (more accurate, deterministic) - ‘ddim’: DDIM sampler (eta controls stochasticity) - ‘ddpm’: DDPM sampler (stochastic)
eta (float) – Stochasticity parameter for DDIM (0=deterministic, 1=stochastic)
return_trajectory (bool) – If True, return all intermediate steps
silent (bool) – If True, hide progress bar
**sampler_kwargs – Additional kwargs passed to sampler
- Returns:
Generated samples (B, T, C, W, H) Or if return_trajectory=True: List of tensors
- Return type: