Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
b282b47b
Commit
b282b47b
authored
Jul 06, 2024
by
AUTOMATIC1111
Committed by
GitHub
Jul 06, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16149 from AndreyRGW/devpatch1
Add Normal and DDIM Schedulers
parents
c02e3a55
f8640662
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
modules/sd_schedulers.py
modules/sd_schedulers.py
+29
-0
No files found.
modules/sd_schedulers.py
View file @
b282b47b
...
@@ -76,6 +76,33 @@ def kl_optimal(n, sigma_min, sigma_max, device):
...
@@ -76,6 +76,33 @@ def kl_optimal(n, sigma_min, sigma_max, device):
sigmas
=
torch
.
tan
(
step_indices
/
n
*
alpha_min
+
(
1.0
-
step_indices
/
n
)
*
alpha_max
)
sigmas
=
torch
.
tan
(
step_indices
/
n
*
alpha_min
+
(
1.0
-
step_indices
/
n
)
*
alpha_max
)
return
sigmas
return
sigmas
def
normal_scheduler
(
n
,
sigma_min
,
sigma_max
,
inner_model
,
device
,
sgm
=
False
,
floor
=
False
):
start
=
inner_model
.
sigma_to_t
(
torch
.
tensor
(
sigma_max
))
end
=
inner_model
.
sigma_to_t
(
torch
.
tensor
(
sigma_min
))
if
sgm
:
timesteps
=
torch
.
linspace
(
start
,
end
,
n
+
1
)[:
-
1
]
else
:
timesteps
=
torch
.
linspace
(
start
,
end
,
n
)
sigs
=
[]
for
x
in
range
(
len
(
timesteps
)):
ts
=
timesteps
[
x
]
sigs
.
append
(
inner_model
.
t_to_sigma
(
ts
))
sigs
+=
[
0.0
]
return
torch
.
FloatTensor
(
sigs
)
.
to
(
device
)
def
ddim_scheduler
(
n
,
sigma_min
,
sigma_max
,
inner_model
,
device
):
sigs
=
[]
ss
=
max
(
len
(
inner_model
.
sigmas
)
//
n
,
1
)
x
=
1
while
x
<
len
(
inner_model
.
sigmas
):
sigs
+=
[
float
(
inner_model
.
sigmas
[
x
])]
x
+=
ss
sigs
=
sigs
[::
-
1
]
sigs
+=
[
0.0
]
return
torch
.
FloatTensor
(
sigs
)
.
to
(
device
)
schedulers
=
[
schedulers
=
[
Scheduler
(
'automatic'
,
'Automatic'
,
None
),
Scheduler
(
'automatic'
,
'Automatic'
,
None
),
...
@@ -86,6 +113,8 @@ schedulers = [
...
@@ -86,6 +113,8 @@ schedulers = [
Scheduler
(
'sgm_uniform'
,
'SGM Uniform'
,
sgm_uniform
,
need_inner_model
=
True
,
aliases
=
[
"SGMUniform"
]),
Scheduler
(
'sgm_uniform'
,
'SGM Uniform'
,
sgm_uniform
,
need_inner_model
=
True
,
aliases
=
[
"SGMUniform"
]),
Scheduler
(
'kl_optimal'
,
'KL Optimal'
,
kl_optimal
),
Scheduler
(
'kl_optimal'
,
'KL Optimal'
,
kl_optimal
),
Scheduler
(
'align_your_steps'
,
'Align Your Steps'
,
get_align_your_steps_sigmas
),
Scheduler
(
'align_your_steps'
,
'Align Your Steps'
,
get_align_your_steps_sigmas
),
Scheduler
(
'normal'
,
'Normal'
,
normal_scheduler
,
need_inner_model
=
True
),
Scheduler
(
'ddim'
,
'DDIM'
,
ddim_scheduler
,
need_inner_model
=
True
),
]
]
schedulers_map
=
{
**
{
x
.
name
:
x
for
x
in
schedulers
},
**
{
x
.
label
:
x
for
x
in
schedulers
}}
schedulers_map
=
{
**
{
x
.
name
:
x
for
x
in
schedulers
},
**
{
x
.
label
:
x
for
x
in
schedulers
}}
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