Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
e222246b
Unverified
Commit
e222246b
authored
Dec 18, 2024
by
hlky
Committed by
GitHub
Dec 18, 2024
Browse files
Fix sigma_last with use_flow_sigmas (#10267)
parent
83709d5a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
0 deletions
+14
-0
src/diffusers/schedulers/scheduling_deis_multistep.py
src/diffusers/schedulers/scheduling_deis_multistep.py
+1
-0
src/diffusers/schedulers/scheduling_dpmsolver_multistep_inverse.py
...sers/schedulers/scheduling_dpmsolver_multistep_inverse.py
+3
-0
src/diffusers/schedulers/scheduling_sasolver.py
src/diffusers/schedulers/scheduling_sasolver.py
+1
-0
src/diffusers/schedulers/scheduling_unipc_multistep.py
src/diffusers/schedulers/scheduling_unipc_multistep.py
+9
-0
No files found.
src/diffusers/schedulers/scheduling_deis_multistep.py
View file @
e222246b
...
...
@@ -289,6 +289,7 @@ class DEISMultistepScheduler(SchedulerMixin, ConfigMixin):
sigmas
=
1.0
-
alphas
sigmas
=
np
.
flip
(
self
.
config
.
flow_shift
*
sigmas
/
(
1
+
(
self
.
config
.
flow_shift
-
1
)
*
sigmas
))[:
-
1
].
copy
()
timesteps
=
(
sigmas
*
self
.
config
.
num_train_timesteps
).
copy
()
sigmas
=
np
.
concatenate
([
sigmas
,
sigmas
[
-
1
:]]).
astype
(
np
.
float32
)
else
:
sigmas
=
np
.
interp
(
timesteps
,
np
.
arange
(
0
,
len
(
sigmas
)),
sigmas
)
sigma_last
=
((
1
-
self
.
alphas_cumprod
[
0
])
/
self
.
alphas_cumprod
[
0
])
**
0.5
...
...
src/diffusers/schedulers/scheduling_dpmsolver_multistep_inverse.py
View file @
e222246b
...
...
@@ -291,14 +291,17 @@ class DPMSolverMultistepInverseScheduler(SchedulerMixin, ConfigMixin):
elif
self
.
config
.
use_exponential_sigmas
:
sigmas
=
self
.
_convert_to_exponential
(
in_sigmas
=
sigmas
,
num_inference_steps
=
num_inference_steps
)
timesteps
=
np
.
array
([
self
.
_sigma_to_t
(
sigma
,
log_sigmas
)
for
sigma
in
sigmas
])
sigmas
=
np
.
concatenate
([
sigmas
,
sigmas
[
-
1
:]]).
astype
(
np
.
float32
)
elif
self
.
config
.
use_beta_sigmas
:
sigmas
=
self
.
_convert_to_beta
(
in_sigmas
=
sigmas
,
num_inference_steps
=
num_inference_steps
)
timesteps
=
np
.
array
([
self
.
_sigma_to_t
(
sigma
,
log_sigmas
)
for
sigma
in
sigmas
])
sigmas
=
np
.
concatenate
([
sigmas
,
sigmas
[
-
1
:]]).
astype
(
np
.
float32
)
elif
self
.
config
.
use_flow_sigmas
:
alphas
=
np
.
linspace
(
1
,
1
/
self
.
config
.
num_train_timesteps
,
num_inference_steps
+
1
)
sigmas
=
1.0
-
alphas
sigmas
=
np
.
flip
(
self
.
config
.
flow_shift
*
sigmas
/
(
1
+
(
self
.
config
.
flow_shift
-
1
)
*
sigmas
))[:
-
1
].
copy
()
timesteps
=
(
sigmas
*
self
.
config
.
num_train_timesteps
).
copy
()
sigmas
=
np
.
concatenate
([
sigmas
,
sigmas
[
-
1
:]]).
astype
(
np
.
float32
)
else
:
sigmas
=
np
.
interp
(
timesteps
,
np
.
arange
(
0
,
len
(
sigmas
)),
sigmas
)
sigma_max
=
(
...
...
src/diffusers/schedulers/scheduling_sasolver.py
View file @
e222246b
...
...
@@ -318,6 +318,7 @@ class SASolverScheduler(SchedulerMixin, ConfigMixin):
sigmas
=
1.0
-
alphas
sigmas
=
np
.
flip
(
self
.
config
.
flow_shift
*
sigmas
/
(
1
+
(
self
.
config
.
flow_shift
-
1
)
*
sigmas
))[:
-
1
].
copy
()
timesteps
=
(
sigmas
*
self
.
config
.
num_train_timesteps
).
copy
()
sigmas
=
np
.
concatenate
([
sigmas
,
sigmas
[
-
1
:]]).
astype
(
np
.
float32
)
else
:
sigmas
=
np
.
interp
(
timesteps
,
np
.
arange
(
0
,
len
(
sigmas
)),
sigmas
)
sigma_last
=
((
1
-
self
.
alphas_cumprod
[
0
])
/
self
.
alphas_cumprod
[
0
])
**
0.5
...
...
src/diffusers/schedulers/scheduling_unipc_multistep.py
View file @
e222246b
...
...
@@ -381,6 +381,15 @@ class UniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
sigmas
=
1.0
-
alphas
sigmas
=
np
.
flip
(
self
.
config
.
flow_shift
*
sigmas
/
(
1
+
(
self
.
config
.
flow_shift
-
1
)
*
sigmas
))[:
-
1
].
copy
()
timesteps
=
(
sigmas
*
self
.
config
.
num_train_timesteps
).
copy
()
if
self
.
config
.
final_sigmas_type
==
"sigma_min"
:
sigma_last
=
sigmas
[
-
1
]
elif
self
.
config
.
final_sigmas_type
==
"zero"
:
sigma_last
=
0
else
:
raise
ValueError
(
f
"`final_sigmas_type` must be one of 'zero', or 'sigma_min', but got
{
self
.
config
.
final_sigmas_type
}
"
)
sigmas
=
np
.
concatenate
([
sigmas
,
[
sigma_last
]]).
astype
(
np
.
float32
)
else
:
sigmas
=
np
.
interp
(
timesteps
,
np
.
arange
(
0
,
len
(
sigmas
)),
sigmas
)
if
self
.
config
.
final_sigmas_type
==
"sigma_min"
:
...
...
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