1616# and https://github.com/hojonathanho/diffusion 
1717
1818from  dataclasses  import  dataclass 
19- from  typing  import  List ,  Optional , Tuple , Union 
19+ from  typing  import  Optional , Tuple , Union 
2020
2121import  numpy  as  np 
2222import  torch 
@@ -57,45 +57,14 @@ class SCMScheduler(SchedulerMixin, ConfigMixin):
5757    Args: 
5858        num_train_timesteps (`int`, defaults to 1000): 
5959            The number of diffusion steps to train the model. 
60-         beta_start (`float`, defaults to 0.0001): 
61-             The starting `beta` value of inference. 
62-         beta_end (`float`, defaults to 0.02): 
63-             The final `beta` value. 
64-         beta_schedule (`str`, defaults to `"linear"`): 
65-             The beta schedule, a mapping from a beta range to a sequence of betas for stepping the model. Choose from 
66-             `linear`, `scaled_linear`, or `squaredcos_cap_v2`. 
67-         trained_betas (`np.ndarray`, *optional*): 
68-             Pass an array of betas directly to the constructor to bypass `beta_start` and `beta_end`. 
69-         clip_sample (`bool`, defaults to `True`): 
70-             Clip the predicted sample for numerical stability. 
71-         clip_sample_range (`float`, defaults to 1.0): 
72-             The maximum magnitude for sample clipping. Valid only when `clip_sample=True`. 
73-         set_alpha_to_one (`bool`, defaults to `True`): 
74-             Each diffusion step uses the alphas product value at that step and at the previous one. For the final step 
75-             there is no previous alpha. When this option is `True` the previous alpha product is fixed to `1`, 
76-             otherwise it uses the alpha value at step 0. 
77-         steps_offset (`int`, defaults to 0): 
78-             An offset added to the inference steps. You can use a combination of `offset=1` and 
79-             `set_alpha_to_one=False` to make the last step use step 0 for the previous alpha product like in Stable 
80-             Diffusion. 
81-         prediction_type (`str`, defaults to `epsilon`, *optional*): 
82-             Prediction type of the scheduler function; can be `epsilon` (predicts the noise of the diffusion process), 
83-             `sample` (directly predicts the noisy sample`) or `v_prediction` (see section 2.4 of [Imagen 
84-             Video](https://imagen.research.google/video/paper.pdf) paper). 
85-         thresholding (`bool`, defaults to `False`): 
86-             Whether to use the "dynamic thresholding" method. This is unsuitable for latent-space diffusion models such 
87-             as Stable Diffusion. 
88-         dynamic_thresholding_ratio (`float`, defaults to 0.995): 
89-             The ratio for the dynamic thresholding method. Valid only when `thresholding=True`. 
90-         sample_max_value (`float`, defaults to 1.0): 
91-             The threshold value for dynamic thresholding. Valid only when `thresholding=True`. 
92-         timestep_spacing (`str`, defaults to `"leading"`): 
93-             The way the timesteps should be scaled. Refer to Table 2 of the [Common Diffusion Noise Schedules and 
94-             Sample Steps are Flawed](https://huggingface.co/papers/2305.08891) for more information. 
95-         rescale_betas_zero_snr (`bool`, defaults to `False`): 
96-             Whether to rescale the betas to have zero terminal SNR. This enables the model to generate very bright and 
97-             dark samples instead of limiting it to samples with medium brightness. Loosely related to 
98-             [`--offset_noise`](https://github.com/huggingface/diffusers/blob/74fd735eb073eb1d774b1ab4154a0876eb82f055/examples/dreambooth/train_dreambooth.py#L506). 
60+         prediction_type (`str`, defaults to `trigflow`): 
61+             Prediction type of the scheduler function. Currently only supports "trigflow". 
62+         max_timesteps (`float`, defaults to 1.57080): 
63+             The maximum timestep value used in the diffusion process. 
64+         intermediate_timesteps (`float`, *optional*, defaults to 1.3): 
65+             The intermediate timestep value used when num_inference_steps=2. 
66+         sigma_data (`float`, defaults to 0.5): 
67+             The standard deviation of the noise added during multi-step inference. 
9968    """ 
10069
10170    # _compatibles = [e.name for e in KarrasDiffusionSchedulers] 
@@ -105,24 +74,26 @@ class SCMScheduler(SchedulerMixin, ConfigMixin):
10574    def  __init__ (
10675        self ,
10776        num_train_timesteps : int  =  1000 ,
108-         beta_start : float  =  0.0001 ,
109-         beta_end : float  =  0.02 ,
110-         beta_schedule : str  =  "linear" ,
111-         trained_betas : Optional [Union [np .ndarray , List [float ]]] =  None ,
112-         clip_sample : bool  =  True ,
113-         set_alpha_to_one : bool  =  True ,
114-         steps_offset : int  =  0 ,
11577        prediction_type : str  =  "trigflow" ,
116-         thresholding : bool  =  False ,
117-         dynamic_thresholding_ratio : float  =  0.995 ,
118-         clip_sample_range : float  =  1.0 ,
119-         sample_max_value : float  =  1.0 ,
120-         timestep_spacing : str  =  "leading" ,
121-         rescale_betas_zero_snr : bool  =  False ,
12278        max_timesteps : float  =  1.57080 ,
123-         intermediate_timesteps : Optional [int ] =  1.3 ,
79+         intermediate_timesteps : Optional [float ] =  1.3 ,
12480        sigma_data : float  =  0.5 ,
12581    ):
82+         """ 
83+         Initialize the SCM scheduler. 
84+ 
85+         Args: 
86+             num_train_timesteps (`int`, defaults to 1000): 
87+                 The number of diffusion steps to train the model. 
88+             prediction_type (`str`, defaults to `trigflow`): 
89+                 Prediction type of the scheduler function. Currently only supports "trigflow". 
90+             max_timesteps (`float`, defaults to 1.57080): 
91+                 The maximum timestep value used in the diffusion process. 
92+             intermediate_timesteps (`float`, *optional*, defaults to 1.3): 
93+                 The intermediate timestep value used when num_inference_steps=2. 
94+             sigma_data (`float`, defaults to 0.5): 
95+                 The standard deviation of the noise added during multi-step inference. 
96+         """ 
12697        # standard deviation of the initial noise distribution 
12798        self .init_noise_sigma  =  1.0 
12899
0 commit comments