FlowMatchEulerDiscreteScheduler (original) (raw)

FlowMatchEulerDiscreteScheduler is based on the flow-matching sampling introduced in Stable Diffusion 3.

class diffusers.FlowMatchEulerDiscreteScheduler

< source >

( num_train_timesteps: int = 1000 shift: float = 1.0 use_dynamic_shifting: bool = False base_shift: typing.Optional[float] = 0.5 max_shift: typing.Optional[float] = 1.15 base_image_seq_len: typing.Optional[int] = 256 max_image_seq_len: typing.Optional[int] = 4096 invert_sigmas: bool = False shift_terminal: typing.Optional[float] = None use_karras_sigmas: typing.Optional[bool] = False use_exponential_sigmas: typing.Optional[bool] = False use_beta_sigmas: typing.Optional[bool] = False time_shift_type: str = 'exponential' stochastic_sampling: bool = False )

Parameters

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

scale_noise

< source >

( sample: FloatTensor timestep: typing.Union[float, torch.FloatTensor] noise: typing.Optional[torch.FloatTensor] = None ) → torch.FloatTensor

Parameters

Returns

torch.FloatTensor

A scaled input sample.

Forward process in flow-matching

set_begin_index

< source >

( begin_index: int = 0 )

Parameters

Sets the begin index for the scheduler. This function should be run from pipeline before the inference.

set_timesteps

< source >

( num_inference_steps: typing.Optional[int] = None device: typing.Union[str, torch.device] = None sigmas: typing.Optional[typing.List[float]] = None mu: typing.Optional[float] = None timesteps: typing.Optional[typing.List[float]] = None )

Parameters

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 per_token_timesteps: typing.Optional[torch.Tensor] = None return_dict: bool = True ) → FlowMatchEulerDiscreteSchedulerOutput or tuple

Parameters

Returns

FlowMatchEulerDiscreteSchedulerOutput or tuple

If return_dict is True,FlowMatchEulerDiscreteSchedulerOutput 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).