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
c1488ff3
Unverified
Commit
c1488ff3
authored
Aug 11, 2022
by
Suraj Patil
Committed by
GitHub
Aug 11, 2022
Browse files
add scaled_linear schedule in PNDM and DDPM (#164)
parent
b344c953
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
0 deletions
+6
-0
src/diffusers/schedulers/scheduling_ddpm.py
src/diffusers/schedulers/scheduling_ddpm.py
+3
-0
src/diffusers/schedulers/scheduling_pndm.py
src/diffusers/schedulers/scheduling_pndm.py
+3
-0
No files found.
src/diffusers/schedulers/scheduling_ddpm.py
View file @
c1488ff3
...
@@ -65,6 +65,9 @@ class DDPMScheduler(SchedulerMixin, ConfigMixin):
...
@@ -65,6 +65,9 @@ class DDPMScheduler(SchedulerMixin, ConfigMixin):
self
.
betas
=
np
.
asarray
(
trained_betas
)
self
.
betas
=
np
.
asarray
(
trained_betas
)
elif
beta_schedule
==
"linear"
:
elif
beta_schedule
==
"linear"
:
self
.
betas
=
np
.
linspace
(
beta_start
,
beta_end
,
num_train_timesteps
,
dtype
=
np
.
float32
)
self
.
betas
=
np
.
linspace
(
beta_start
,
beta_end
,
num_train_timesteps
,
dtype
=
np
.
float32
)
elif
beta_schedule
==
"scaled_linear"
:
# this schedule is very specific to the latent diffusion model.
self
.
betas
=
np
.
linspace
(
beta_start
**
0.5
,
beta_end
**
0.5
,
num_train_timesteps
,
dtype
=
np
.
float32
)
**
2
elif
beta_schedule
==
"squaredcos_cap_v2"
:
elif
beta_schedule
==
"squaredcos_cap_v2"
:
# Glide cosine schedule
# Glide cosine schedule
self
.
betas
=
betas_for_alpha_bar
(
num_train_timesteps
)
self
.
betas
=
betas_for_alpha_bar
(
num_train_timesteps
)
...
...
src/diffusers/schedulers/scheduling_pndm.py
View file @
c1488ff3
...
@@ -60,6 +60,9 @@ class PNDMScheduler(SchedulerMixin, ConfigMixin):
...
@@ -60,6 +60,9 @@ class PNDMScheduler(SchedulerMixin, ConfigMixin):
if
beta_schedule
==
"linear"
:
if
beta_schedule
==
"linear"
:
self
.
betas
=
np
.
linspace
(
beta_start
,
beta_end
,
num_train_timesteps
,
dtype
=
np
.
float32
)
self
.
betas
=
np
.
linspace
(
beta_start
,
beta_end
,
num_train_timesteps
,
dtype
=
np
.
float32
)
elif
beta_schedule
==
"scaled_linear"
:
# this schedule is very specific to the latent diffusion model.
self
.
betas
=
np
.
linspace
(
beta_start
**
0.5
,
beta_end
**
0.5
,
num_train_timesteps
,
dtype
=
np
.
float32
)
**
2
elif
beta_schedule
==
"squaredcos_cap_v2"
:
elif
beta_schedule
==
"squaredcos_cap_v2"
:
# Glide cosine schedule
# Glide cosine schedule
self
.
betas
=
betas_for_alpha_bar
(
num_train_timesteps
)
self
.
betas
=
betas_for_alpha_bar
(
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