Unverified Commit d45bb937 authored by Wenliang Zhao's avatar Wenliang Zhao Committed by GitHub
Browse files

[Docs] Fix UniPC docs (#2386)

* fix typos in the doc

* restyle the code
parent 568b73fd
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# DISCLAIMER: This file is strongly influenced by https://github.com/LuChengTHU/dpm-solver # DISCLAIMER: check https://arxiv.org/abs/2302.04867 and https://github.com/wl-zhao/UniPC for more info
# The codebase is modified based on https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_dpmsolver_multistep.py
import math import math
from typing import List, Optional, Tuple, Union from typing import List, Optional, Tuple, Union
...@@ -67,9 +68,8 @@ class UniPCMultistepScheduler(SchedulerMixin, ConfigMixin): ...@@ -67,9 +68,8 @@ class UniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
to use `solver_order=2` for guided sampling, and `solver_order=3` for unconditional sampling. to use `solver_order=2` for guided sampling, and `solver_order=3` for unconditional sampling.
We also support the "dynamic thresholding" method in Imagen (https://arxiv.org/abs/2205.11487). For pixel-space We also support the "dynamic thresholding" method in Imagen (https://arxiv.org/abs/2205.11487). For pixel-space
diffusion models, you can set both `algorithm_type="dpmsolver++"` and `thresholding=True` to use the dynamic diffusion models, you can set both `predict_x0=True` and `thresholding=True` to use the dynamic thresholding. Note
thresholding. Note that the thresholding method is unsuitable for latent-space diffusion models (such as that the thresholding method is unsuitable for latent-space diffusion models (such as stable-diffusion).
stable-diffusion).
[`~ConfigMixin`] takes care of storing all config attributes that are passed in the scheduler's `__init__` [`~ConfigMixin`] takes care of storing all config attributes that are passed in the scheduler's `__init__`
function, such as `num_train_timesteps`. They can be accessed via `scheduler.config.num_train_timesteps`. function, such as `num_train_timesteps`. They can be accessed via `scheduler.config.num_train_timesteps`.
...@@ -95,9 +95,9 @@ class UniPCMultistepScheduler(SchedulerMixin, ConfigMixin): ...@@ -95,9 +95,9 @@ class UniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
https://imagen.research.google/video/paper.pdf) https://imagen.research.google/video/paper.pdf)
thresholding (`bool`, default `False`): thresholding (`bool`, default `False`):
whether to use the "dynamic thresholding" method (introduced by Imagen, https://arxiv.org/abs/2205.11487). whether to use the "dynamic thresholding" method (introduced by Imagen, https://arxiv.org/abs/2205.11487).
For pixel-space diffusion models, you can set both `algorithm_type=dpmsolver++` and `thresholding=True` to For pixel-space diffusion models, you can set both `predict_x0=True` and `thresholding=True` to use the
use the dynamic thresholding. Note that the thresholding method is unsuitable for latent-space diffusion dynamic thresholding. Note that the thresholding method is unsuitable for latent-space diffusion models
models (such as stable-diffusion). (such as stable-diffusion).
dynamic_thresholding_ratio (`float`, default `0.995`): dynamic_thresholding_ratio (`float`, default `0.995`):
the ratio for the dynamic thresholding method. Default is `0.995`, the same as Imagen the ratio for the dynamic thresholding method. Default is `0.995`, the same as Imagen
(https://arxiv.org/abs/2205.11487). (https://arxiv.org/abs/2205.11487).
...@@ -136,7 +136,7 @@ class UniPCMultistepScheduler(SchedulerMixin, ConfigMixin): ...@@ -136,7 +136,7 @@ class UniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
dynamic_thresholding_ratio: float = 0.995, dynamic_thresholding_ratio: float = 0.995,
sample_max_value: float = 1.0, sample_max_value: float = 1.0,
predict_x0: bool = True, predict_x0: bool = True,
solver_type: str = "bh1", solver_type: str = "bh2",
lower_order_final: bool = True, lower_order_final: bool = True,
disable_corrector: List[int] = [], disable_corrector: List[int] = [],
solver_p: SchedulerMixin = None, solver_p: SchedulerMixin = None,
...@@ -237,7 +237,7 @@ class UniPCMultistepScheduler(SchedulerMixin, ConfigMixin): ...@@ -237,7 +237,7 @@ class UniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
else: else:
raise ValueError( raise ValueError(
f"prediction_type given as {self.config.prediction_type} must be one of `epsilon`, `sample`, or" f"prediction_type given as {self.config.prediction_type} must be one of `epsilon`, `sample`, or"
" `v_prediction` for the DPMSolverMultistepScheduler." " `v_prediction` for the UniPCMultistepScheduler."
) )
if self.config.thresholding: if self.config.thresholding:
...@@ -269,7 +269,7 @@ class UniPCMultistepScheduler(SchedulerMixin, ConfigMixin): ...@@ -269,7 +269,7 @@ class UniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
else: else:
raise ValueError( raise ValueError(
f"prediction_type given as {self.config.prediction_type} must be one of `epsilon`, `sample`, or" f"prediction_type given as {self.config.prediction_type} must be one of `epsilon`, `sample`, or"
" `v_prediction` for the DPMSolverMultistepScheduler." " `v_prediction` for the UniPCMultistepScheduler."
) )
def multistep_uni_p_bh_update( def multistep_uni_p_bh_update(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment