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.
- diffusers/__init__.py +3 -1
- diffusers/commands/fp16_safetensors.py +2 -7
- diffusers/configuration_utils.py +23 -1
- diffusers/dependency_versions_table.py +1 -1
- diffusers/loaders.py +62 -64
- diffusers/models/__init__.py +1 -0
- diffusers/models/activations.py +2 -0
- diffusers/models/attention.py +45 -1
- diffusers/models/autoencoder_tiny.py +193 -0
- diffusers/models/controlnet.py +1 -1
- diffusers/models/embeddings.py +56 -0
- diffusers/models/lora.py +0 -6
- diffusers/models/modeling_flax_utils.py +28 -2
- diffusers/models/modeling_utils.py +33 -16
- diffusers/models/transformer_2d.py +26 -9
- diffusers/models/unet_1d.py +2 -2
- diffusers/models/unet_2d_blocks.py +106 -56
- diffusers/models/unet_2d_condition.py +20 -5
- diffusers/models/vae.py +106 -1
- diffusers/pipelines/__init__.py +1 -0
- diffusers/pipelines/alt_diffusion/pipeline_alt_diffusion.py +10 -3
- diffusers/pipelines/alt_diffusion/pipeline_alt_diffusion_img2img.py +10 -3
- diffusers/pipelines/audioldm/pipeline_audioldm.py +1 -1
- diffusers/pipelines/auto_pipeline.py +33 -43
- diffusers/pipelines/controlnet/multicontrolnet.py +4 -2
- diffusers/pipelines/controlnet/pipeline_controlnet.py +20 -4
- diffusers/pipelines/controlnet/pipeline_controlnet_img2img.py +15 -7
- diffusers/pipelines/controlnet/pipeline_controlnet_inpaint.py +14 -4
- diffusers/pipelines/controlnet/pipeline_controlnet_sd_xl.py +157 -10
- diffusers/pipelines/controlnet/pipeline_flax_controlnet.py +2 -10
- diffusers/pipelines/deepfloyd_if/pipeline_if.py +1 -1
- diffusers/pipelines/deepfloyd_if/pipeline_if_img2img.py +1 -1
- diffusers/pipelines/deepfloyd_if/pipeline_if_img2img_superresolution.py +1 -1
- diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting.py +1 -1
- diffusers/pipelines/deepfloyd_if/pipeline_if_inpainting_superresolution.py +1 -1
- diffusers/pipelines/deepfloyd_if/pipeline_if_superresolution.py +1 -1
- diffusers/pipelines/kandinsky/pipeline_kandinsky_combined.py +43 -2
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_combined.py +44 -2
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_controlnet_img2img.py +1 -1
- diffusers/pipelines/kandinsky2_2/pipeline_kandinsky2_2_img2img.py +1 -1
- diffusers/pipelines/pipeline_flax_utils.py +41 -4
- diffusers/pipelines/pipeline_utils.py +60 -16
- diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py +2 -2
- diffusers/pipelines/stable_diffusion/__init__.py +1 -0
- diffusers/pipelines/stable_diffusion/convert_from_ckpt.py +81 -37
- diffusers/pipelines/stable_diffusion/pipeline_cycle_diffusion.py +10 -3
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py +10 -3
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_attend_and_excite.py +10 -3
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py +10 -3
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_diffedit.py +12 -5
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_gligen.py +832 -0
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py +10 -3
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py +10 -3
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint_legacy.py +10 -3
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_k_diffusion.py +9 -2
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_ldm3d.py +17 -8
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py +10 -3
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_panorama.py +10 -3
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_paradigms.py +10 -3
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_pix2pix_zero.py +10 -3
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_sag.py +10 -3
- diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py +10 -3
- diffusers/pipelines/stable_diffusion/pipeline_stable_unclip.py +10 -3
- diffusers/pipelines/stable_diffusion/pipeline_stable_unclip_img2img.py +10 -3
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py +3 -5
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_img2img.py +75 -3
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_inpaint.py +76 -6
- diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl_instruct_pix2pix.py +1 -2
- diffusers/pipelines/t2i_adapter/pipeline_stable_diffusion_adapter.py +10 -3
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth.py +10 -3
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_synth_img2img.py +11 -4
- diffusers/pipelines/text_to_video_synthesis/pipeline_text_to_video_zero.py +1 -1
- diffusers/pipelines/versatile_diffusion/modeling_text_unet.py +131 -28
- diffusers/schedulers/scheduling_consistency_models.py +70 -57
- diffusers/schedulers/scheduling_ddim.py +76 -71
- diffusers/schedulers/scheduling_ddim_inverse.py +76 -44
- diffusers/schedulers/scheduling_ddim_parallel.py +11 -8
- diffusers/schedulers/scheduling_ddpm.py +68 -67
- diffusers/schedulers/scheduling_ddpm_parallel.py +18 -15
- diffusers/schedulers/scheduling_deis_multistep.py +93 -85
- diffusers/schedulers/scheduling_dpmsolver_multistep.py +118 -120
- diffusers/schedulers/scheduling_dpmsolver_multistep_inverse.py +116 -109
- diffusers/schedulers/scheduling_dpmsolver_sde.py +57 -43
- diffusers/schedulers/scheduling_dpmsolver_singlestep.py +122 -121
- diffusers/schedulers/scheduling_euler_ancestral_discrete.py +54 -44
- diffusers/schedulers/scheduling_euler_discrete.py +63 -56
- diffusers/schedulers/scheduling_heun_discrete.py +57 -45
- diffusers/schedulers/scheduling_ipndm.py +27 -22
- diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py +54 -41
- diffusers/schedulers/scheduling_k_dpm_2_discrete.py +52 -41
- diffusers/schedulers/scheduling_karras_ve.py +55 -45
- diffusers/schedulers/scheduling_lms_discrete.py +58 -52
- diffusers/schedulers/scheduling_pndm.py +77 -62
- diffusers/schedulers/scheduling_repaint.py +56 -38
- diffusers/schedulers/scheduling_sde_ve.py +62 -50
- diffusers/schedulers/scheduling_sde_vp.py +32 -11
- diffusers/schedulers/scheduling_unclip.py +3 -3
- diffusers/schedulers/scheduling_unipc_multistep.py +131 -91
- diffusers/schedulers/scheduling_utils.py +41 -35
- diffusers/schedulers/scheduling_utils_flax.py +8 -2
- diffusers/schedulers/scheduling_vq_diffusion.py +39 -68
- diffusers/utils/__init__.py +2 -2
- diffusers/utils/dummy_pt_objects.py +15 -0
- diffusers/utils/dummy_torch_and_transformers_objects.py +15 -0
- diffusers/utils/hub_utils.py +105 -2
- diffusers/utils/import_utils.py +0 -4
- diffusers/utils/pil_utils.py +19 -0
- {diffusers-0.19.3.dist-info → diffusers-0.20.1.dist-info}/METADATA +5 -7
- {diffusers-0.19.3.dist-info → diffusers-0.20.1.dist-info}/RECORD +113 -112
- {diffusers-0.19.3.dist-info → diffusers-0.20.1.dist-info}/WHEEL +1 -1
- {diffusers-0.19.3.dist-info → diffusers-0.20.1.dist-info}/entry_points.txt +0 -1
- diffusers/models/cross_attention.py +0 -94
- {diffusers-0.19.3.dist-info → diffusers-0.20.1.dist-info}/LICENSE +0 -0
- {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
|
-
|
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
|
-
|
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
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
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
|
-
|
107
|
-
solver_order (`int`,
|
108
|
-
|
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`,
|
111
|
-
|
112
|
-
|
113
|
-
https://imagen.research.google/video/paper.pdf)
|
114
|
-
thresholding (`bool`,
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
`
|
125
|
-
|
126
|
-
|
127
|
-
`sde-dpmsolver
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
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
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
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.
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
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
|
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
|
-
|
238
|
-
device (`str` or `torch.device`, optional):
|
239
|
-
|
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
|
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
|
-
|
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
|
-
|
375
|
-
|
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`):
|
379
|
-
|
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
|
361
|
+
A current instance of a sample created by the diffusion process.
|
382
362
|
|
383
363
|
Returns:
|
384
|
-
`torch.FloatTensor`:
|
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
|
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`):
|
454
|
-
|
455
|
-
|
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
|
439
|
+
A current instance of a sample created by the diffusion process.
|
458
440
|
|
459
441
|
Returns:
|
460
|
-
`torch.FloatTensor`:
|
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
|
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`):
|
501
|
-
|
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
|
488
|
+
A current instance of a sample created by the diffusion process.
|
504
489
|
|
505
490
|
Returns:
|
506
|
-
`torch.FloatTensor`:
|
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
|
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`):
|
592
|
-
|
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
|
582
|
+
A current instance of a sample created by diffusion process.
|
595
583
|
|
596
584
|
Returns:
|
597
|
-
`torch.FloatTensor`:
|
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
|
-
|
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`):
|
646
|
-
|
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
|
649
|
-
|
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`:
|
653
|
-
|
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`):
|
713
|
+
sample (`torch.FloatTensor`):
|
714
|
+
The input sample.
|
718
715
|
|
719
716
|
Returns:
|
720
|
-
`torch.FloatTensor`:
|
717
|
+
`torch.FloatTensor`:
|
718
|
+
A scaled input sample.
|
721
719
|
"""
|
722
720
|
return sample
|
723
721
|
|