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
chenpangpang
diffusers
Commits
df9c0701
Unverified
Commit
df9c0701
authored
Oct 06, 2022
by
Anton Lozhkov
Committed by
GitHub
Oct 06, 2022
Browse files
Add back-compatibility to LMS timesteps (#750)
* Add back-compatibility to LMS timesteps * style
parent
c119dc4c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
7 deletions
+20
-7
src/diffusers/schedulers/scheduling_lms_discrete.py
src/diffusers/schedulers/scheduling_lms_discrete.py
+20
-7
No files found.
src/diffusers/schedulers/scheduling_lms_discrete.py
View file @
df9c0701
...
@@ -202,11 +202,6 @@ class LMSDiscreteScheduler(SchedulerMixin, ConfigMixin):
...
@@ -202,11 +202,6 @@ class LMSDiscreteScheduler(SchedulerMixin, ConfigMixin):
When returning a tuple, the first element is the sample tensor.
When returning a tuple, the first element is the sample tensor.
"""
"""
if
not
isinstance
(
timestep
,
float
)
and
not
isinstance
(
timestep
,
torch
.
FloatTensor
):
warnings
.
warn
(
f
"`LMSDiscreteScheduler` timesteps must be `float` or `torch.FloatTensor`, not
{
type
(
timestep
)
}
. "
"Make sure to pass one of the `scheduler.timesteps`"
)
if
not
self
.
is_scale_input_called
:
if
not
self
.
is_scale_input_called
:
warnings
.
warn
(
warnings
.
warn
(
"The `scale_model_input` function should be called before `step` to ensure correct denoising. "
"The `scale_model_input` function should be called before `step` to ensure correct denoising. "
...
@@ -215,6 +210,17 @@ class LMSDiscreteScheduler(SchedulerMixin, ConfigMixin):
...
@@ -215,6 +210,17 @@ class LMSDiscreteScheduler(SchedulerMixin, ConfigMixin):
if
isinstance
(
timestep
,
torch
.
Tensor
):
if
isinstance
(
timestep
,
torch
.
Tensor
):
timestep
=
timestep
.
to
(
self
.
timesteps
.
device
)
timestep
=
timestep
.
to
(
self
.
timesteps
.
device
)
if
(
isinstance
(
timestep
,
int
)
or
isinstance
(
timestep
,
torch
.
IntTensor
)
or
isinstance
(
timestep
,
torch
.
LongTensor
)
):
warnings
.
warn
(
"Integer timesteps in `LMSDiscreteScheduler.step()` are deprecated and will be removed in version"
" 0.5.0. Make sure to pass one of the `scheduler.timesteps`."
)
step_index
=
timestep
else
:
step_index
=
(
self
.
timesteps
==
timestep
).
nonzero
().
item
()
step_index
=
(
self
.
timesteps
==
timestep
).
nonzero
().
item
()
sigma
=
self
.
sigmas
[
step_index
]
sigma
=
self
.
sigmas
[
step_index
]
...
@@ -250,6 +256,13 @@ class LMSDiscreteScheduler(SchedulerMixin, ConfigMixin):
...
@@ -250,6 +256,13 @@ class LMSDiscreteScheduler(SchedulerMixin, ConfigMixin):
sigmas
=
self
.
sigmas
.
to
(
original_samples
.
device
)
sigmas
=
self
.
sigmas
.
to
(
original_samples
.
device
)
schedule_timesteps
=
self
.
timesteps
.
to
(
original_samples
.
device
)
schedule_timesteps
=
self
.
timesteps
.
to
(
original_samples
.
device
)
timesteps
=
timesteps
.
to
(
original_samples
.
device
)
timesteps
=
timesteps
.
to
(
original_samples
.
device
)
if
isinstance
(
timesteps
,
torch
.
IntTensor
)
or
isinstance
(
timesteps
,
torch
.
LongTensor
):
warnings
.
warn
(
"Integer timesteps in `LMSDiscreteScheduler.add_noise()` are deprecated and will be removed in"
" version 0.5.0. Make sure to pass values from `scheduler.timesteps`."
)
step_indices
=
timesteps
else
:
step_indices
=
[(
schedule_timesteps
==
t
).
nonzero
().
item
()
for
t
in
timesteps
]
step_indices
=
[(
schedule_timesteps
==
t
).
nonzero
().
item
()
for
t
in
timesteps
]
sigma
=
sigmas
[
step_indices
].
flatten
()
sigma
=
sigmas
[
step_indices
].
flatten
()
...
...
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