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
aeb76ef1
Commit
aeb76ef1
authored
Aug 14, 2023
by
AUTOMATIC1111
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
repair DDIM/PLMS/UniPC batches
parent
007ecfbb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
modules/sd_samplers_timesteps.py
modules/sd_samplers_timesteps.py
+2
-3
modules/sd_samplers_timesteps_impl.py
modules/sd_samplers_timesteps_impl.py
+10
-8
No files found.
modules/sd_samplers_timesteps.py
View file @
aeb76ef1
...
...
@@ -51,10 +51,9 @@ class CFGDenoiserTimesteps(CFGDenoiser):
self
.
alphas
=
shared
.
sd_model
.
alphas_cumprod
def
get_pred_x0
(
self
,
x_in
,
x_out
,
sigma
):
ts
=
int
(
sigma
.
item
()
)
ts
=
sigma
.
to
(
dtype
=
int
)
s_in
=
x_in
.
new_ones
([
x_in
.
shape
[
0
]])
a_t
=
self
.
alphas
[
ts
]
.
item
()
*
s_in
a_t
=
self
.
alphas
[
ts
][:,
None
,
None
,
None
]
sqrt_one_minus_at
=
(
1
-
a_t
)
.
sqrt
()
pred_x0
=
(
x_in
-
sqrt_one_minus_at
*
x_out
)
/
a_t
.
sqrt
()
...
...
modules/sd_samplers_timesteps_impl.py
View file @
aeb76ef1
...
...
@@ -16,16 +16,17 @@ def ddim(model, x, timesteps, extra_args=None, callback=None, disable=None, eta=
sigmas
=
eta
*
np
.
sqrt
((
1
-
alphas_prev
.
cpu
()
.
numpy
())
/
(
1
-
alphas
.
cpu
())
*
(
1
-
alphas
.
cpu
()
/
alphas_prev
.
cpu
()
.
numpy
()))
extra_args
=
{}
if
extra_args
is
None
else
extra_args
s_in
=
x
.
new_ones
([
x
.
shape
[
0
]])
s_in
=
x
.
new_ones
((
x
.
shape
[
0
]))
s_x
=
x
.
new_ones
((
x
.
shape
[
0
],
1
,
1
,
1
))
for
i
in
tqdm
.
trange
(
len
(
timesteps
)
-
1
,
disable
=
disable
):
index
=
len
(
timesteps
)
-
1
-
i
e_t
=
model
(
x
,
timesteps
[
index
]
.
item
()
*
s_in
,
**
extra_args
)
a_t
=
alphas
[
index
]
.
item
()
*
s_
in
a_prev
=
alphas_prev
[
index
]
.
item
()
*
s_
in
sigma_t
=
sigmas
[
index
]
.
item
()
*
s_
in
sqrt_one_minus_at
=
sqrt_one_minus_alphas
[
index
]
.
item
()
*
s_
in
a_t
=
alphas
[
index
]
.
item
()
*
s_
x
a_prev
=
alphas_prev
[
index
]
.
item
()
*
s_
x
sigma_t
=
sigmas
[
index
]
.
item
()
*
s_
x
sqrt_one_minus_at
=
sqrt_one_minus_alphas
[
index
]
.
item
()
*
s_
x
pred_x0
=
(
x
-
sqrt_one_minus_at
*
e_t
)
/
a_t
.
sqrt
()
dir_xt
=
(
1.
-
a_prev
-
sigma_t
**
2
)
.
sqrt
()
*
e_t
...
...
@@ -47,13 +48,14 @@ def plms(model, x, timesteps, extra_args=None, callback=None, disable=None):
extra_args
=
{}
if
extra_args
is
None
else
extra_args
s_in
=
x
.
new_ones
([
x
.
shape
[
0
]])
s_x
=
x
.
new_ones
((
x
.
shape
[
0
],
1
,
1
,
1
))
old_eps
=
[]
def
get_x_prev_and_pred_x0
(
e_t
,
index
):
# select parameters corresponding to the currently considered timestep
a_t
=
alphas
[
index
]
.
item
()
*
s_
in
a_prev
=
alphas_prev
[
index
]
.
item
()
*
s_
in
sqrt_one_minus_at
=
sqrt_one_minus_alphas
[
index
]
.
item
()
*
s_
in
a_t
=
alphas
[
index
]
.
item
()
*
s_
x
a_prev
=
alphas_prev
[
index
]
.
item
()
*
s_
x
sqrt_one_minus_at
=
sqrt_one_minus_alphas
[
index
]
.
item
()
*
s_
x
# current prediction for x_0
pred_x0
=
(
x
-
sqrt_one_minus_at
*
e_t
)
/
a_t
.
sqrt
()
...
...
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