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
f45c675d
Unverified
Commit
f45c675d
authored
Jan 03, 2023
by
aengusng8
Committed by
GitHub
Jan 03, 2023
Browse files
[addresses issue #1642] add add_noise to scheduling-sde-ve (#1827)
* add add_noise to scheduling-sde-ve * run Black formater
parent
1bf4f0da
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
src/diffusers/schedulers/scheduling_sde_ve.py
src/diffusers/schedulers/scheduling_sde_ve.py
+13
-0
No files found.
src/diffusers/schedulers/scheduling_sde_ve.py
View file @
f45c675d
...
@@ -262,5 +262,18 @@ class ScoreSdeVeScheduler(SchedulerMixin, ConfigMixin):
...
@@ -262,5 +262,18 @@ class ScoreSdeVeScheduler(SchedulerMixin, ConfigMixin):
return
SchedulerOutput
(
prev_sample
=
prev_sample
)
return
SchedulerOutput
(
prev_sample
=
prev_sample
)
def
add_noise
(
self
,
original_samples
:
torch
.
FloatTensor
,
noise
:
torch
.
FloatTensor
,
timesteps
:
torch
.
FloatTensor
,
)
->
torch
.
FloatTensor
:
# Make sure sigmas and timesteps have the same device and dtype as original_samples
timesteps
=
timesteps
.
to
(
original_samples
.
device
)
sigmas
=
self
.
discrete_sigmas
.
to
(
original_samples
.
device
)[
timesteps
]
noise
=
torch
.
randn_like
(
original_samples
)
*
sigmas
[:,
None
,
None
,
None
]
noisy_samples
=
noise
+
original_samples
return
noisy_samples
def
__len__
(
self
):
def
__len__
(
self
):
return
self
.
config
.
num_train_timesteps
return
self
.
config
.
num_train_timesteps
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