Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
diffusers
Commits
d45bb937
Unverified
Commit
d45bb937
authored
Feb 17, 2023
by
Wenliang Zhao
Committed by
GitHub
Feb 17, 2023
Browse files
[Docs] Fix UniPC docs (#2386)
* fix typos in the doc * restyle the code
parent
568b73fd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
src/diffusers/schedulers/scheduling_unipc_multistep.py
src/diffusers/schedulers/scheduling_unipc_multistep.py
+10
-10
No files found.
src/diffusers/schedulers/scheduling_unipc_multistep.py
View file @
d45bb937
...
@@ -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
=
"bh
1
"
,
solver_type
:
str
=
"bh
2
"
,
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
DPMSolver
MultistepScheduler."
" `v_prediction` for the
UniPC
MultistepScheduler."
)
)
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
DPMSolver
MultistepScheduler."
" `v_prediction` for the
UniPC
MultistepScheduler."
)
)
def
multistep_uni_p_bh_update
(
def
multistep_uni_p_bh_update
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment