diffusers 0.19.3__py3-none-any.whl → 0.20.1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. diffusers/__init__.py +3 -1
  2. diffusers/commands/fp16_safetensors.py +2 -7
  3. diffusers/configuration_utils.py +23 -1
  4. diffusers/dependency_versions_table.py +1 -1
  5. diffusers/loaders.py +62 -64
  6. diffusers/models/__init__.py +1 -0
  7. diffusers/models/activations.py +2 -0
  8. diffusers/models/attention.py +45 -1
  9. diffusers/models/autoencoder_tiny.py +193 -0
  10. diffusers/models/controlnet.py +1 -1
  11. diffusers/models/embeddings.py +56 -0
  12. diffusers/models/lora.py +0 -6
  13. diffusers/models/modeling_flax_utils.py +28 -2
  14. diffusers/models/modeling_utils.py +33 -16
  15. diffusers/models/transformer_2d.py +26 -9
  16. diffusers/models/unet_1d.py +2 -2
  17. diffusers/models/unet_2d_blocks.py +106 -56
  18. diffusers/models/unet_2d_condition.py +20 -5
  19. diffusers/models/vae.py +106 -1
  20. diffusers/pipelines/__init__.py +1 -0
  21. diffusers/pipelines/alt_diffusion/pipeline_alt_diffusion.py +10 -3
  22. diffusers/pipelines/alt_diffusion/pipeline_alt_diffusion_img2img.py +10 -3
  23. diffusers/pipelines/audioldm/pipeline_audioldm.py +1 -1
  24. diffusers/pipelines/auto_pipeline.py +33 -43
  25. diffusers/pipelines/controlnet/multicontrolnet.py +4 -2
  26. diffusers/pipelines/controlnet/pipeline_controlnet.py +20 -4
  27. diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +15 -7
  28. diffusers/pipelines/controlnet/pipeline_controlnet_inpaint.py +14 -4
  29. diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py +157 -10
  30. diffusers/pipelines/controlnet/pipeline_flax_controlnet.py +2 -10
  31. diffusers/pipelines/deepfloyd_if/pipeline_if.py +1 -1
  32. diffusers/pipelines/deepfloyd_if/pipeline_if_img2img.py +1 -1
  33. diffusers/pipelines/deepfloyd_if/pipeline_if_img2img_superresolution.py +1 -1
  34. diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting.py +1 -1
  35. diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting_superresolution.py +1 -1
  36. diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py +1 -1
  37. diffusers/pipelines/kandinsky/pipeline_kandinsky_combined.py +43 -2
  38. diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_combined.py +44 -2
  39. diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_controlnet_img2img.py +1 -1
  40. diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_img2img.py +1 -1
  41. diffusers/pipelines/pipeline_flax_utils.py +41 -4
  42. diffusers/pipelines/pipeline_utils.py +60 -16
  43. diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py +2 -2
  44. diffusers/pipelines/stable_diffusion/__init__.py +1 -0
  45. diffusers/pipelines/stable_diffusion/convert_from_ckpt.py +81 -37
  46. diffusers/pipelines/stable_diffusion/pipeline_cycle_diffusion.py +10 -3
  47. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +10 -3
  48. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_attend_and_excite.py +10 -3
  49. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py +10 -3
  50. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_diffedit.py +12 -5
  51. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_gligen.py +832 -0
  52. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +10 -3
  53. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py +10 -3
  54. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint_legacy.py +10 -3
  55. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_k_diffusion.py +9 -2
  56. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_ldm3d.py +17 -8
  57. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py +10 -3
  58. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_panorama.py +10 -3
  59. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py +10 -3
  60. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_pix2pix_zero.py +10 -3
  61. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_sag.py +10 -3
  62. diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py +10 -3
  63. diffusers/pipelines/stable_diffusion/pipeline_stable_unclip.py +10 -3
  64. diffusers/pipelines/stable_diffusion/pipeline_stable_unclip_img2img.py +10 -3
  65. diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py +3 -5
  66. diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py +75 -3
  67. diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py +76 -6
  68. diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_instruct_pix2pix.py +1 -2
  69. diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_adapter.py +10 -3
  70. diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth.py +10 -3
  71. diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth_img2img.py +11 -4
  72. diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero.py +1 -1
  73. diffusers/pipelines/versatile_diffusion/modeling_text_unet.py +131 -28
  74. diffusers/schedulers/scheduling_consistency_models.py +70 -57
  75. diffusers/schedulers/scheduling_ddim.py +76 -71
  76. diffusers/schedulers/scheduling_ddim_inverse.py +76 -44
  77. diffusers/schedulers/scheduling_ddim_parallel.py +11 -8
  78. diffusers/schedulers/scheduling_ddpm.py +68 -67
  79. diffusers/schedulers/scheduling_ddpm_parallel.py +18 -15
  80. diffusers/schedulers/scheduling_deis_multistep.py +93 -85
  81. diffusers/schedulers/scheduling_dpmsolver_multistep.py +118 -120
  82. diffusers/schedulers/scheduling_dpmsolver_multistep_inverse.py +116 -109
  83. diffusers/schedulers/scheduling_dpmsolver_sde.py +57 -43
  84. diffusers/schedulers/scheduling_dpmsolver_singlestep.py +122 -121
  85. diffusers/schedulers/scheduling_euler_ancestral_discrete.py +54 -44
  86. diffusers/schedulers/scheduling_euler_discrete.py +63 -56
  87. diffusers/schedulers/scheduling_heun_discrete.py +57 -45
  88. diffusers/schedulers/scheduling_ipndm.py +27 -22
  89. diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py +54 -41
  90. diffusers/schedulers/scheduling_k_dpm_2_discrete.py +52 -41
  91. diffusers/schedulers/scheduling_karras_ve.py +55 -45
  92. diffusers/schedulers/scheduling_lms_discrete.py +58 -52
  93. diffusers/schedulers/scheduling_pndm.py +77 -62
  94. diffusers/schedulers/scheduling_repaint.py +56 -38
  95. diffusers/schedulers/scheduling_sde_ve.py +62 -50
  96. diffusers/schedulers/scheduling_sde_vp.py +32 -11
  97. diffusers/schedulers/scheduling_unclip.py +3 -3
  98. diffusers/schedulers/scheduling_unipc_multistep.py +131 -91
  99. diffusers/schedulers/scheduling_utils.py +41 -35
  100. diffusers/schedulers/scheduling_utils_flax.py +8 -2
  101. diffusers/schedulers/scheduling_vq_diffusion.py +39 -68
  102. diffusers/utils/__init__.py +2 -2
  103. diffusers/utils/dummy_pt_objects.py +15 -0
  104. diffusers/utils/dummy_torch_and_transformers_objects.py +15 -0
  105. diffusers/utils/hub_utils.py +105 -2
  106. diffusers/utils/import_utils.py +0 -4
  107. diffusers/utils/pil_utils.py +19 -0
  108. {diffusers-0.19.3.dist-info → diffusers-0.20.1.dist-info}/METADATA +5 -7
  109. {diffusers-0.19.3.dist-info → diffusers-0.20.1.dist-info}/RECORD +113 -112
  110. {diffusers-0.19.3.dist-info → diffusers-0.20.1.dist-info}/WHEEL +1 -1
  111. {diffusers-0.19.3.dist-info → diffusers-0.20.1.dist-info}/entry_points.txt +0 -1
  112. diffusers/models/cross_attention.py +0 -94
  113. {diffusers-0.19.3.dist-info → diffusers-0.20.1.dist-info}/LICENSE +0 -0
  114. {diffusers-0.19.3.dist-info → diffusers-0.20.1.dist-info}/top_level.txt +0 -0
@@ -72,90 +72,66 @@ def betas_for_alpha_bar(
72
72
 
73
73
  class DPMSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
74
74
  """
75
- DPM-Solver (and the improved version DPM-Solver++) is a fast dedicated high-order solver for diffusion ODEs with
76
- the convergence order guarantee. Empirically, sampling by DPM-Solver with only 20 steps can generate high-quality
77
- samples, and it can generate quite good samples even in only 10 steps.
75
+ `DPMSolverMultistepScheduler` is a fast dedicated high-order solver for diffusion ODEs.
78
76
 
79
- For more details, see the original paper: https://arxiv.org/abs/2206.00927 and https://arxiv.org/abs/2211.01095
80
-
81
- Currently, we support the multistep DPM-Solver for both noise prediction models and data prediction models. We
82
- recommend to use `solver_order=2` for guided sampling, and `solver_order=3` for unconditional sampling.
83
-
84
- We also support the "dynamic thresholding" method in Imagen (https://arxiv.org/abs/2205.11487). For pixel-space
85
- diffusion models, you can set both `algorithm_type="dpmsolver++"` and `thresholding=True` to use the dynamic
86
- thresholding. Note that the thresholding method is unsuitable for latent-space diffusion models (such as
87
- stable-diffusion).
88
-
89
- We also support the SDE variant of DPM-Solver and DPM-Solver++, which is a fast SDE solver for the reverse
90
- diffusion SDE. Currently we only support the first-order and second-order solvers. We recommend using the
91
- second-order `sde-dpmsolver++`.
92
-
93
- [`~ConfigMixin`] takes care of storing all config attributes that are passed in the scheduler's `__init__`
94
- function, such as `num_train_timesteps`. They can be accessed via `scheduler.config.num_train_timesteps`.
95
- [`SchedulerMixin`] provides general loading and saving functionality via the [`SchedulerMixin.save_pretrained`] and
96
- [`~SchedulerMixin.from_pretrained`] functions.
77
+ This model inherits from [`SchedulerMixin`] and [`ConfigMixin`]. Check the superclass documentation for the generic
78
+ methods the library implements for all schedulers such as loading and saving.
97
79
 
98
80
  Args:
99
- num_train_timesteps (`int`): number of diffusion steps used to train the model.
100
- beta_start (`float`): the starting `beta` value of inference.
101
- beta_end (`float`): the final `beta` value.
102
- beta_schedule (`str`):
103
- the beta schedule, a mapping from a beta range to a sequence of betas for stepping the model. Choose from
81
+ num_train_timesteps (`int`, defaults to 1000):
82
+ The number of diffusion steps to train the model.
83
+ beta_start (`float`, defaults to 0.0001):
84
+ The starting `beta` value of inference.
85
+ beta_end (`float`, defaults to 0.02):
86
+ The final `beta` value.
87
+ beta_schedule (`str`, defaults to `"linear"`):
88
+ The beta schedule, a mapping from a beta range to a sequence of betas for stepping the model. Choose from
104
89
  `linear`, `scaled_linear`, or `squaredcos_cap_v2`.
105
- trained_betas (`np.ndarray`, optional):
106
- option to pass an array of betas directly to the constructor to bypass `beta_start`, `beta_end` etc.
107
- solver_order (`int`, default `2`):
108
- the order of DPM-Solver; can be `1` or `2` or `3`. We recommend to use `solver_order=2` for guided
90
+ trained_betas (`np.ndarray`, *optional*):
91
+ Pass an array of betas directly to the constructor to bypass `beta_start` and `beta_end`.
92
+ solver_order (`int`, defaults to 2):
93
+ The DPMSolver order which can be `1` or `2` or `3`. It is recommended to use `solver_order=2` for guided
109
94
  sampling, and `solver_order=3` for unconditional sampling.
110
- prediction_type (`str`, default `epsilon`, optional):
111
- prediction type of the scheduler function, one of `epsilon` (predicting the noise of the diffusion
112
- process), `sample` (directly predicting the noisy sample`) or `v_prediction` (see section 2.4
113
- https://imagen.research.google/video/paper.pdf)
114
- thresholding (`bool`, default `False`):
115
- whether to use the "dynamic thresholding" method (introduced by Imagen, https://arxiv.org/abs/2205.11487).
116
- For pixel-space diffusion models, you can set both `algorithm_type=dpmsolver++` and `thresholding=True` to
117
- use the dynamic thresholding. Note that the thresholding method is unsuitable for latent-space diffusion
118
- models (such as stable-diffusion).
119
- dynamic_thresholding_ratio (`float`, default `0.995`):
120
- the ratio for the dynamic thresholding method. Default is `0.995`, the same as Imagen
121
- (https://arxiv.org/abs/2205.11487).
122
- sample_max_value (`float`, default `1.0`):
123
- the threshold value for dynamic thresholding. Valid only when `thresholding=True` and
124
- `algorithm_type="dpmsolver++`.
125
- algorithm_type (`str`, default `dpmsolver++`):
126
- the algorithm type for the solver. Either `dpmsolver` or `dpmsolver++` or `sde-dpmsolver` or
127
- `sde-dpmsolver++`. The `dpmsolver` type implements the algorithms in https://arxiv.org/abs/2206.00927, and
128
- the `dpmsolver++` type implements the algorithms in https://arxiv.org/abs/2211.01095. We recommend to use
129
- `dpmsolver++` or `sde-dpmsolver++` with `solver_order=2` for guided sampling (e.g. stable-diffusion).
130
- solver_type (`str`, default `midpoint`):
131
- the solver type for the second-order solver. Either `midpoint` or `heun`. The solver type slightly affects
132
- the sample quality, especially for small number of steps. We empirically find that `midpoint` solvers are
133
- slightly better, so we recommend to use the `midpoint` type.
134
- lower_order_final (`bool`, default `True`):
135
- whether to use lower-order solvers in the final steps. Only valid for < 15 inference steps. We empirically
136
- find this trick can stabilize the sampling of DPM-Solver for steps < 15, especially for steps <= 10.
95
+ prediction_type (`str`, defaults to `epsilon`, *optional*):
96
+ Prediction type of the scheduler function; can be `epsilon` (predicts the noise of the diffusion process),
97
+ `sample` (directly predicts the noisy sample`) or `v_prediction` (see section 2.4 of [Imagen
98
+ Video](https://imagen.research.google/video/paper.pdf) paper).
99
+ thresholding (`bool`, defaults to `False`):
100
+ Whether to use the "dynamic thresholding" method. This is unsuitable for latent-space diffusion models such
101
+ as Stable Diffusion.
102
+ dynamic_thresholding_ratio (`float`, defaults to 0.995):
103
+ The ratio for the dynamic thresholding method. Valid only when `thresholding=True`.
104
+ sample_max_value (`float`, defaults to 1.0):
105
+ The threshold value for dynamic thresholding. Valid only when `thresholding=True` and
106
+ `algorithm_type="dpmsolver++"`.
107
+ algorithm_type (`str`, defaults to `dpmsolver++`):
108
+ Algorithm type for the solver; can be `dpmsolver`, `dpmsolver++`, `sde-dpmsolver` or `sde-dpmsolver++`. The
109
+ `dpmsolver` type implements the algorithms in the [DPMSolver](https://huggingface.co/papers/2206.00927)
110
+ paper, and the `dpmsolver++` type implements the algorithms in the
111
+ [DPMSolver++](https://huggingface.co/papers/2211.01095) paper. It is recommended to use `dpmsolver++` or
112
+ `sde-dpmsolver++` with `solver_order=2` for guided sampling like in Stable Diffusion.
113
+ solver_type (`str`, defaults to `midpoint`):
114
+ Solver type for the second-order solver; can be `midpoint` or `heun`. The solver type slightly affects the
115
+ sample quality, especially for a small number of steps. It is recommended to use `midpoint` solvers.
116
+ lower_order_final (`bool`, defaults to `True`):
117
+ Whether to use lower-order solvers in the final steps. Only valid for < 15 inference steps. This can
118
+ stabilize the sampling of DPMSolver for steps < 15, especially for steps <= 10.
137
119
  use_karras_sigmas (`bool`, *optional*, defaults to `False`):
138
- This parameter controls whether to use Karras sigmas (Karras et al. (2022) scheme) for step sizes in the
139
- noise schedule during the sampling process. If True, the sigmas will be determined according to a sequence
140
- of noise levels {σi} as defined in Equation (5) of the paper https://arxiv.org/pdf/2206.00364.pdf.
141
- lambda_min_clipped (`float`, default `-inf`):
142
- the clipping threshold for the minimum value of lambda(t) for numerical stability. This is critical for
143
- cosine (squaredcos_cap_v2) noise schedule.
120
+ Whether to use Karras sigmas for step sizes in the noise schedule during the sampling process. If `True`,
121
+ the sigmas are determined according to a sequence of noise levels {σi}.
122
+ lambda_min_clipped (`float`, defaults to `-inf`):
123
+ Clipping threshold for the minimum value of `lambda(t)` for numerical stability. This is critical for the
124
+ cosine (`squaredcos_cap_v2`) noise schedule.
144
125
  variance_type (`str`, *optional*):
145
- Set to "learned" or "learned_range" for diffusion models that predict variance. For example, OpenAI's
146
- guided-diffusion (https://github.com/openai/guided-diffusion) predicts both mean and variance of the
147
- Gaussian distribution in the model's output. DPM-Solver only needs the "mean" output because it is based on
148
- diffusion ODEs. whether the model's output contains the predicted Gaussian variance. For example, OpenAI's
149
- guided-diffusion (https://github.com/openai/guided-diffusion) predicts both mean and variance of the
150
- Gaussian distribution in the model's output. DPM-Solver only needs the "mean" output because it is based on
151
- diffusion ODEs.
152
- timestep_spacing (`str`, default `"linspace"`):
153
- The way the timesteps should be scaled. Refer to Table 2. of [Common Diffusion Noise Schedules and Sample
154
- Steps are Flawed](https://arxiv.org/abs/2305.08891) for more information.
155
- steps_offset (`int`, default `0`):
156
- an offset added to the inference steps. You can use a combination of `offset=1` and
157
- `set_alpha_to_one=False`, to make the last step use step 0 for the previous alpha product, as done in
158
- stable diffusion.
126
+ Set to "learned" or "learned_range" for diffusion models that predict variance. If set, the model's output
127
+ contains the predicted Gaussian variance.
128
+ timestep_spacing (`str`, defaults to `"linspace"`):
129
+ The way the timesteps should be scaled. Refer to Table 2 of the [Common Diffusion Noise Schedules and
130
+ Sample Steps are Flawed](https://huggingface.co/papers/2305.08891) for more information.
131
+ steps_offset (`int`, defaults to 0):
132
+ An offset added to the inference steps. You can use a combination of `offset=1` and
133
+ `set_alpha_to_one=False` to make the last step use step 0 for the previous alpha product like in Stable
134
+ Diffusion.
159
135
  """
160
136
 
161
137
  _compatibles = [e.name for e in KarrasDiffusionSchedulers]
@@ -230,13 +206,13 @@ class DPMSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
230
206
 
231
207
  def set_timesteps(self, num_inference_steps: int = None, device: Union[str, torch.device] = None):
232
208
  """
233
- Sets the timesteps used for the diffusion chain. Supporting function to be run before inference.
209
+ Sets the discrete timesteps used for the diffusion chain (to be run before inference).
234
210
 
235
211
  Args:
236
212
  num_inference_steps (`int`):
237
- the number of diffusion steps used when generating samples with a pre-trained model.
238
- device (`str` or `torch.device`, optional):
239
- the device to which the timesteps should be moved to. If `None`, the timesteps are not moved.
213
+ The number of diffusion steps used when generating samples with a pre-trained model.
214
+ device (`str` or `torch.device`, *optional*):
215
+ The device to which the timesteps should be moved to. If `None`, the timesteps are not moved.
240
216
  """
241
217
  # Clipping the minimum of all lambda(t) for numerical stability.
242
218
  # This is critical for cosine (squaredcos_cap_v2) noise schedule.
@@ -365,23 +341,28 @@ class DPMSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
365
341
  self, model_output: torch.FloatTensor, timestep: int, sample: torch.FloatTensor
366
342
  ) -> torch.FloatTensor:
367
343
  """
368
- Convert the model output to the corresponding type that the algorithm (DPM-Solver / DPM-Solver++) needs.
344
+ Convert the model output to the corresponding type the DPMSolver/DPMSolver++ algorithm needs. DPM-Solver is
345
+ designed to discretize an integral of the noise prediction model, and DPM-Solver++ is designed to discretize an
346
+ integral of the data prediction model.
369
347
 
370
- DPM-Solver is designed to discretize an integral of the noise prediction model, and DPM-Solver++ is designed to
371
- discretize an integral of the data prediction model. So we need to first convert the model output to the
372
- corresponding type to match the algorithm.
348
+ <Tip>
373
349
 
374
- Note that the algorithm type and the model type is decoupled. That is to say, we can use either DPM-Solver or
375
- DPM-Solver++ for both noise prediction model and data prediction model.
350
+ The algorithm and model type are decoupled. You can use either DPMSolver or DPMSolver++ for both noise
351
+ prediction and data prediction models.
352
+
353
+ </Tip>
376
354
 
377
355
  Args:
378
- model_output (`torch.FloatTensor`): direct output from learned diffusion model.
379
- timestep (`int`): current discrete timestep in the diffusion chain.
356
+ model_output (`torch.FloatTensor`):
357
+ The direct output from the learned diffusion model.
358
+ timestep (`int`):
359
+ The current discrete timestep in the diffusion chain.
380
360
  sample (`torch.FloatTensor`):
381
- current instance of sample being created by diffusion process.
361
+ A current instance of a sample created by the diffusion process.
382
362
 
383
363
  Returns:
384
- `torch.FloatTensor`: the converted model output.
364
+ `torch.FloatTensor`:
365
+ The converted model output.
385
366
  """
386
367
 
387
368
  # DPM-Solver++ needs to solve an integral of the data prediction model.
@@ -445,19 +426,21 @@ class DPMSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
445
426
  noise: Optional[torch.FloatTensor] = None,
446
427
  ) -> torch.FloatTensor:
447
428
  """
448
- One step for the first-order DPM-Solver (equivalent to DDIM).
449
-
450
- See https://arxiv.org/abs/2206.00927 for the detailed derivation.
429
+ One step for the first-order DPMSolver (equivalent to DDIM).
451
430
 
452
431
  Args:
453
- model_output (`torch.FloatTensor`): direct output from learned diffusion model.
454
- timestep (`int`): current discrete timestep in the diffusion chain.
455
- prev_timestep (`int`): previous discrete timestep in the diffusion chain.
432
+ model_output (`torch.FloatTensor`):
433
+ The direct output from the learned diffusion model.
434
+ timestep (`int`):
435
+ The current discrete timestep in the diffusion chain.
436
+ prev_timestep (`int`):
437
+ The previous discrete timestep in the diffusion chain.
456
438
  sample (`torch.FloatTensor`):
457
- current instance of sample being created by diffusion process.
439
+ A current instance of a sample created by the diffusion process.
458
440
 
459
441
  Returns:
460
- `torch.FloatTensor`: the sample tensor at the previous timestep.
442
+ `torch.FloatTensor`:
443
+ The sample tensor at the previous timestep.
461
444
  """
462
445
  lambda_t, lambda_s = self.lambda_t[prev_timestep], self.lambda_t[timestep]
463
446
  alpha_t, alpha_s = self.alpha_t[prev_timestep], self.alpha_t[timestep]
@@ -492,18 +475,21 @@ class DPMSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
492
475
  noise: Optional[torch.FloatTensor] = None,
493
476
  ) -> torch.FloatTensor:
494
477
  """
495
- One step for the second-order multistep DPM-Solver.
478
+ One step for the second-order multistep DPMSolver.
496
479
 
497
480
  Args:
498
481
  model_output_list (`List[torch.FloatTensor]`):
499
- direct outputs from learned diffusion model at current and latter timesteps.
500
- timestep (`int`): current and latter discrete timestep in the diffusion chain.
501
- prev_timestep (`int`): previous discrete timestep in the diffusion chain.
482
+ The direct outputs from learned diffusion model at current and latter timesteps.
483
+ timestep (`int`):
484
+ The current and latter discrete timestep in the diffusion chain.
485
+ prev_timestep (`int`):
486
+ The previous discrete timestep in the diffusion chain.
502
487
  sample (`torch.FloatTensor`):
503
- current instance of sample being created by diffusion process.
488
+ A current instance of a sample created by the diffusion process.
504
489
 
505
490
  Returns:
506
- `torch.FloatTensor`: the sample tensor at the previous timestep.
491
+ `torch.FloatTensor`:
492
+ The sample tensor at the previous timestep.
507
493
  """
508
494
  t, s0, s1 = prev_timestep, timestep_list[-1], timestep_list[-2]
509
495
  m0, m1 = model_output_list[-1], model_output_list[-2]
@@ -583,18 +569,21 @@ class DPMSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
583
569
  sample: torch.FloatTensor,
584
570
  ) -> torch.FloatTensor:
585
571
  """
586
- One step for the third-order multistep DPM-Solver.
572
+ One step for the third-order multistep DPMSolver.
587
573
 
588
574
  Args:
589
575
  model_output_list (`List[torch.FloatTensor]`):
590
- direct outputs from learned diffusion model at current and latter timesteps.
591
- timestep (`int`): current and latter discrete timestep in the diffusion chain.
592
- prev_timestep (`int`): previous discrete timestep in the diffusion chain.
576
+ The direct outputs from learned diffusion model at current and latter timesteps.
577
+ timestep (`int`):
578
+ The current and latter discrete timestep in the diffusion chain.
579
+ prev_timestep (`int`):
580
+ The previous discrete timestep in the diffusion chain.
593
581
  sample (`torch.FloatTensor`):
594
- current instance of sample being created by diffusion process.
582
+ A current instance of a sample created by diffusion process.
595
583
 
596
584
  Returns:
597
- `torch.FloatTensor`: the sample tensor at the previous timestep.
585
+ `torch.FloatTensor`:
586
+ The sample tensor at the previous timestep.
598
587
  """
599
588
  t, s0, s1, s2 = prev_timestep, timestep_list[-1], timestep_list[-2], timestep_list[-3]
600
589
  m0, m1, m2 = model_output_list[-1], model_output_list[-2], model_output_list[-3]
@@ -639,18 +628,25 @@ class DPMSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
639
628
  return_dict: bool = True,
640
629
  ) -> Union[SchedulerOutput, Tuple]:
641
630
  """
642
- Step function propagating the sample with the multistep DPM-Solver.
631
+ Predict the sample from the previous timestep by reversing the SDE. This function propagates the sample with
632
+ the multistep DPMSolver.
643
633
 
644
634
  Args:
645
- model_output (`torch.FloatTensor`): direct output from learned diffusion model.
646
- timestep (`int`): current discrete timestep in the diffusion chain.
635
+ model_output (`torch.FloatTensor`):
636
+ The direct output from learned diffusion model.
637
+ timestep (`int`):
638
+ The current discrete timestep in the diffusion chain.
647
639
  sample (`torch.FloatTensor`):
648
- current instance of sample being created by diffusion process.
649
- return_dict (`bool`): option for returning tuple rather than SchedulerOutput class
640
+ A current instance of a sample created by the diffusion process.
641
+ generator (`torch.Generator`, *optional*):
642
+ A random number generator.
643
+ return_dict (`bool`):
644
+ Whether or not to return a [`~schedulers.scheduling_utils.SchedulerOutput`] or `tuple`.
650
645
 
651
646
  Returns:
652
- [`~scheduling_utils.SchedulerOutput`] or `tuple`: [`~scheduling_utils.SchedulerOutput`] if `return_dict` is
653
- True, otherwise a `tuple`. When returning a tuple, the first element is the sample tensor.
647
+ [`~schedulers.scheduling_utils.SchedulerOutput`] or `tuple`:
648
+ If return_dict is `True`, [`~schedulers.scheduling_utils.SchedulerOutput`] is returned, otherwise a
649
+ tuple is returned where the first element is the sample tensor.
654
650
 
655
651
  """
656
652
  if self.num_inference_steps is None:
@@ -714,10 +710,12 @@ class DPMSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
714
710
  current timestep.
715
711
 
716
712
  Args:
717
- sample (`torch.FloatTensor`): input sample
713
+ sample (`torch.FloatTensor`):
714
+ The input sample.
718
715
 
719
716
  Returns:
720
- `torch.FloatTensor`: scaled input sample
717
+ `torch.FloatTensor`:
718
+ A scaled input sample.
721
719
  """
722
720
  return sample
723
721