Diffusers documentation
FlowMatchHeunDiscreteScheduler
FlowMatchHeunDiscreteScheduler
FlowMatchHeunDiscreteScheduler is based on the flow-matching sampling introduced in EDM.
FlowMatchHeunDiscreteScheduler
class diffusers.FlowMatchHeunDiscreteScheduler
< source >( num_train_timesteps: int = 1000 shift: float = 1.0 )
Heun scheduler.
This model inherits from SchedulerMixin and ConfigMixin. Check the superclass documentation for the generic methods the library implements for all schedulers such as loading and saving.
index_for_timestep
< source >( timestep: typing.Union[float, torch.FloatTensor] schedule_timesteps: typing.Optional[torch.FloatTensor] = None ) → int
Find the index of a given timestep in the timestep schedule.
scale_noise
< source >( sample: FloatTensor timestep: typing.Union[float, torch.FloatTensor] noise: FloatTensor ) → torch.FloatTensor
Forward process in flow-matching
set_begin_index
< source >( begin_index: int = 0 )
Sets the begin index for the scheduler. This function should be run from pipeline before the inference.
set_timesteps
< source >( num_inference_steps: int device: typing.Union[str, torch.device] = None )
Sets the discrete timesteps used for the diffusion chain (to be run before inference).
step
< source >( model_output: FloatTensor timestep: typing.Union[float, torch.FloatTensor] sample: FloatTensor s_churn: float = 0.0 s_tmin: float = 0.0 s_tmax: float = inf s_noise: float = 1.0 generator: typing.Optional[torch._C.Generator] = None return_dict: bool = True ) → FlowMatchHeunDiscreteSchedulerOutput or tuple
Parameters
- model_output (
torch.FloatTensor) — The direct output from learned diffusion model. - timestep (
floatortorch.FloatTensor) — The current discrete timestep in the diffusion chain. - sample (
torch.FloatTensor) — A current instance of a sample created by the diffusion process. - s_churn (
float) — Stochasticity parameter that controls the amount of noise added during sampling. Higher values increase randomness. - s_tmin (
float) — Minimum timestep threshold for applying stochasticity. Only timesteps above this value will have noise added. - s_tmax (
float) — Maximum timestep threshold for applying stochasticity. Only timesteps below this value will have noise added. - s_noise (
float, defaults to 1.0) — Scaling factor for noise added to the sample. - generator (
torch.Generator, optional) — A random number generator. - return_dict (
bool) — Whether or not to return aFlowMatchHeunDiscreteSchedulerOutputtuple.
Returns
FlowMatchHeunDiscreteSchedulerOutput or tuple
If return_dict is True,
FlowMatchHeunDiscreteSchedulerOutput 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).