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
44e8e9c3
Commit
44e8e9c3
authored
Mar 30, 2023
by
devdn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix live preview & alternate uncond guidance for better quality
parent
bc905920
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
modules/sd_samplers_kdiffusion.py
modules/sd_samplers_kdiffusion.py
+8
-6
No files found.
modules/sd_samplers_kdiffusion.py
View file @
44e8e9c3
...
@@ -116,11 +116,13 @@ class CFGDenoiser(torch.nn.Module):
...
@@ -116,11 +116,13 @@ class CFGDenoiser(torch.nn.Module):
tensor
=
denoiser_params
.
text_cond
tensor
=
denoiser_params
.
text_cond
uncond
=
denoiser_params
.
text_uncond
uncond
=
denoiser_params
.
text_uncond
sigma_thresh
=
s_min_uncond
if
self
.
step
%
2
and
s_min_uncond
>
0
and
not
is_edit_model
:
if
(
torch
.
dot
(
sigma
,
sigma
)
<
sigma
.
shape
[
0
]
*
(
sigma_thresh
*
sigma_thresh
)
and
not
is_edit_model
):
# alternating uncond allows for higher thresholds without the quality loss normally expected from raising it
uncond
=
torch
.
zeros
([
0
,
0
,
uncond
.
shape
[
2
]])
sigma_threshold
=
s_min_uncond
x_in
=
x_in
[:
x_in
.
shape
[
0
]
//
2
]
if
(
torch
.
dot
(
sigma
,
sigma
)
<
sigma
.
shape
[
0
]
*
(
sigma_threshold
*
sigma_threshold
)
):
sigma_in
=
sigma_in
[:
sigma_in
.
shape
[
0
]
//
2
]
uncond
=
torch
.
zeros
([
0
,
0
,
uncond
.
shape
[
2
]])
x_in
=
x_in
[:
x_in
.
shape
[
0
]
//
2
]
sigma_in
=
sigma_in
[:
sigma_in
.
shape
[
0
]
//
2
]
if
tensor
.
shape
[
1
]
==
uncond
.
shape
[
1
]:
if
tensor
.
shape
[
1
]
==
uncond
.
shape
[
1
]:
if
not
is_edit_model
:
if
not
is_edit_model
:
...
@@ -159,7 +161,7 @@ class CFGDenoiser(torch.nn.Module):
...
@@ -159,7 +161,7 @@ class CFGDenoiser(torch.nn.Module):
devices
.
test_for_nans
(
x_out
,
"unet"
)
devices
.
test_for_nans
(
x_out
,
"unet"
)
if
opts
.
live_preview_content
==
"Prompt"
:
if
opts
.
live_preview_content
==
"Prompt"
:
sd_samplers_common
.
store_latent
(
x_out
[
0
:
uncond
.
shape
[
0
]])
sd_samplers_common
.
store_latent
(
x_out
[
0
:
x_out
.
shape
[
0
]
-
uncond
.
shape
[
0
]])
elif
opts
.
live_preview_content
==
"Negative prompt"
:
elif
opts
.
live_preview_content
==
"Negative prompt"
:
sd_samplers_common
.
store_latent
(
x_out
[
-
uncond
.
shape
[
0
]:])
sd_samplers_common
.
store_latent
(
x_out
[
-
uncond
.
shape
[
0
]:])
...
...
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