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
39a6d565
Commit
39a6d565
authored
Jun 08, 2024
by
drhead
Committed by
GitHub
Jun 08, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patch k_diffusion to_d and strip device from schedulers
parent
428975e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
modules/sd_schedulers.py
modules/sd_schedulers.py
+15
-9
No files found.
modules/sd_schedulers.py
View file @
39a6d565
...
@@ -4,6 +4,12 @@ import torch
...
@@ -4,6 +4,12 @@ import torch
import
k_diffusion
import
k_diffusion
def
to_d
(
x
,
sigma
,
denoised
):
"""Converts a denoiser output to a Karras ODE derivative."""
return
(
x
-
denoised
)
/
sigma
k_diffusion
.
sampling
.
to_d
=
to_d
import
numpy
as
np
import
numpy
as
np
from
modules
import
shared
from
modules
import
shared
...
@@ -19,11 +25,11 @@ class Scheduler:
...
@@ -19,11 +25,11 @@ class Scheduler:
aliases
:
list
=
None
aliases
:
list
=
None
def
uniform
(
n
,
sigma_min
,
sigma_max
,
inner_model
,
device
):
def
uniform
(
n
,
sigma_min
,
sigma_max
,
inner_model
):
return
inner_model
.
get_sigmas
(
n
)
return
inner_model
.
get_sigmas
(
n
)
def
sgm_uniform
(
n
,
sigma_min
,
sigma_max
,
inner_model
,
device
):
def
sgm_uniform
(
n
,
sigma_min
,
sigma_max
,
inner_model
):
start
=
inner_model
.
sigma_to_t
(
torch
.
tensor
(
sigma_max
))
start
=
inner_model
.
sigma_to_t
(
torch
.
tensor
(
sigma_max
))
end
=
inner_model
.
sigma_to_t
(
torch
.
tensor
(
sigma_min
))
end
=
inner_model
.
sigma_to_t
(
torch
.
tensor
(
sigma_min
))
sigs
=
[
sigs
=
[
...
@@ -31,9 +37,9 @@ def sgm_uniform(n, sigma_min, sigma_max, inner_model, device):
...
@@ -31,9 +37,9 @@ def sgm_uniform(n, sigma_min, sigma_max, inner_model, device):
for
ts
in
torch
.
linspace
(
start
,
end
,
n
+
1
)[:
-
1
]
for
ts
in
torch
.
linspace
(
start
,
end
,
n
+
1
)[:
-
1
]
]
]
sigs
+=
[
0.0
]
sigs
+=
[
0.0
]
return
torch
.
FloatTensor
(
sigs
)
.
to
(
device
)
return
torch
.
FloatTensor
(
sigs
)
def
get_align_your_steps_sigmas
(
n
,
sigma_min
,
sigma_max
,
device
=
'cpu'
):
def
get_align_your_steps_sigmas
(
n
,
sigma_min
,
sigma_max
):
# https://research.nvidia.com/labs/toronto-ai/AlignYourSteps/howto.html
# https://research.nvidia.com/labs/toronto-ai/AlignYourSteps/howto.html
def
loglinear_interp
(
t_steps
,
num_steps
):
def
loglinear_interp
(
t_steps
,
num_steps
):
"""
"""
...
@@ -59,12 +65,12 @@ def get_align_your_steps_sigmas(n, sigma_min, sigma_max, device='cpu'):
...
@@ -59,12 +65,12 @@ def get_align_your_steps_sigmas(n, sigma_min, sigma_max, device='cpu'):
else
:
else
:
sigmas
.
append
(
0.0
)
sigmas
.
append
(
0.0
)
return
torch
.
FloatTensor
(
sigmas
)
.
to
(
device
)
return
torch
.
FloatTensor
(
sigmas
)
def
kl_optimal
(
n
,
sigma_min
,
sigma_max
,
device
):
def
kl_optimal
(
n
,
sigma_min
,
sigma_max
):
alpha_min
=
torch
.
arctan
(
torch
.
tensor
(
sigma_min
,
device
=
device
))
alpha_min
=
torch
.
arctan
(
torch
.
tensor
(
sigma_min
))
alpha_max
=
torch
.
arctan
(
torch
.
tensor
(
sigma_max
,
device
=
device
))
alpha_max
=
torch
.
arctan
(
torch
.
tensor
(
sigma_max
))
step_indices
=
torch
.
arange
(
n
+
1
,
device
=
device
)
step_indices
=
torch
.
arange
(
n
+
1
)
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
...
...
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