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
79ffb945
Commit
79ffb945
authored
Feb 10, 2023
by
space-nuko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add UniPC sampler settings
parent
c88dcc20
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
3 deletions
+16
-3
modules/models/diffusion/uni_pc/sampler.py
modules/models/diffusion/uni_pc/sampler.py
+3
-2
modules/models/diffusion/uni_pc/uni_pc.py
modules/models/diffusion/uni_pc/uni_pc.py
+1
-1
modules/shared.py
modules/shared.py
+5
-0
scripts/xyz_grid.py
scripts/xyz_grid.py
+7
-0
No files found.
modules/models/diffusion/uni_pc/sampler.py
View file @
79ffb945
...
...
@@ -3,6 +3,7 @@
import
torch
from
.uni_pc
import
NoiseScheduleVP
,
model_wrapper
,
UniPC
from
modules
import
shared
class
UniPCSampler
(
object
):
def
__init__
(
self
,
model
,
**
kwargs
):
...
...
@@ -89,7 +90,7 @@ class UniPCSampler(object):
guidance_scale
=
unconditional_guidance_scale
,
)
uni_pc
=
UniPC
(
model_fn
,
ns
,
predict_x0
=
True
,
thresholding
=
False
,
condition
=
conditioning
,
unconditional_condition
=
unconditional_conditioning
,
before_sample
=
self
.
before_sample
,
after_sample
=
self
.
after_sample
,
after_update
=
self
.
after_update
)
x
=
uni_pc
.
sample
(
img
,
steps
=
S
,
skip_type
=
"time_uniform"
,
method
=
"multistep"
,
order
=
3
,
lower_order_final
=
True
)
uni_pc
=
UniPC
(
model_fn
,
ns
,
predict_x0
=
True
,
thresholding
=
shared
.
opts
.
uni_pc_thresholding
,
variant
=
shared
.
opts
.
uni_pc_variant
,
condition
=
conditioning
,
unconditional_condition
=
unconditional_conditioning
,
before_sample
=
self
.
before_sample
,
after_sample
=
self
.
after_sample
,
after_update
=
self
.
after_update
)
x
=
uni_pc
.
sample
(
img
,
steps
=
S
,
skip_type
=
shared
.
opts
.
uni_pc_skip_type
,
method
=
"multistep"
,
order
=
shared
.
opts
.
uni_pc_order
,
lower_order_final
=
shared
.
opts
.
uni_pc_lower_order_final
)
return
x
.
to
(
device
),
None
modules/models/diffusion/uni_pc/uni_pc.py
View file @
79ffb945
...
...
@@ -750,7 +750,7 @@ class UniPC:
if
method
==
'multistep'
:
assert
steps
>=
order
,
"UniPC order must be < sampling steps"
timesteps
=
self
.
get_time_steps
(
skip_type
=
skip_type
,
t_T
=
t_T
,
t_0
=
t_0
,
N
=
steps
,
device
=
device
)
print
(
f
"Running UniPC Sampling with {timesteps.shape[0]} timesteps"
)
print
(
f
"Running UniPC Sampling with {timesteps.shape[0]} timesteps
, order {order}
"
)
assert
timesteps
.
shape
[
0
]
-
1
==
steps
with
torch
.
no_grad
():
vec_t
=
timesteps
[
0
]
.
expand
((
x
.
shape
[
0
]))
...
...
modules/shared.py
View file @
79ffb945
...
...
@@ -480,6 +480,11 @@ options_templates.update(options_section(('sampler-params', "Sampler parameters"
's_noise'
:
OptionInfo
(
1.0
,
"sigma noise"
,
gr
.
Slider
,
{
"minimum"
:
0.0
,
"maximum"
:
1.0
,
"step"
:
0.01
}),
'eta_noise_seed_delta'
:
OptionInfo
(
0
,
"Eta noise seed delta"
,
gr
.
Number
,
{
"precision"
:
0
}),
'always_discard_next_to_last_sigma'
:
OptionInfo
(
False
,
"Always discard next-to-last sigma"
),
'uni_pc_variant'
:
OptionInfo
(
"bh1"
,
"UniPC variant"
,
gr
.
Radio
,
{
"choices"
:
[
"bh1"
,
"vary_coeff"
]}),
'uni_pc_skip_type'
:
OptionInfo
(
"time_uniform"
,
"UniPC skip type"
,
gr
.
Radio
,
{
"choices"
:
[
"time_uniform"
,
"time_quadratic"
,
"logSNR"
]}),
'uni_pc_order'
:
OptionInfo
(
3
,
"UniPC order (must be < sampling steps)"
,
gr
.
Slider
,
{
"minimum"
:
1
,
"maximum"
:
150
-
1
,
"step"
:
1
}),
'uni_pc_thresholding'
:
OptionInfo
(
False
,
"UniPC thresholding"
),
'uni_pc_lower_order_final'
:
OptionInfo
(
True
,
"UniPC lower order final"
),
}))
options_templates
.
update
(
options_section
((
'postprocessing'
,
"Postprocessing"
),
{
...
...
scripts/xyz_grid.py
View file @
79ffb945
...
...
@@ -126,6 +126,10 @@ def apply_styles(p: StableDiffusionProcessingTxt2Img, x: str, _):
p
.
styles
.
extend
(
x
.
split
(
','
))
def
apply_uni_pc_order
(
p
,
x
,
xs
):
opts
.
data
[
"uni_pc_order"
]
=
min
(
x
,
p
.
steps
-
1
)
def
format_value_add_label
(
p
,
opt
,
x
):
if
type
(
x
)
==
float
:
x
=
round
(
x
,
8
)
...
...
@@ -202,6 +206,7 @@ axis_options = [
AxisOptionImg2Img
(
"Cond. Image Mask Weight"
,
float
,
apply_field
(
"inpainting_mask_weight"
)),
AxisOption
(
"VAE"
,
str
,
apply_vae
,
cost
=
0.7
,
choices
=
lambda
:
list
(
sd_vae
.
vae_dict
)),
AxisOption
(
"Styles"
,
str
,
apply_styles
,
choices
=
lambda
:
list
(
shared
.
prompt_styles
.
styles
)),
AxisOption
(
"UniPC Order"
,
int
,
apply_uni_pc_order
,
cost
=
0.5
),
]
...
...
@@ -310,9 +315,11 @@ class SharedSettingsStackHelper(object):
def
__enter__
(
self
):
self
.
CLIP_stop_at_last_layers
=
opts
.
CLIP_stop_at_last_layers
self
.
vae
=
opts
.
sd_vae
self
.
uni_pc_order
=
opts
.
uni_pc_order
def
__exit__
(
self
,
exc_type
,
exc_value
,
tb
):
opts
.
data
[
"sd_vae"
]
=
self
.
vae
opts
.
data
[
"uni_pc_order"
]
=
self
.
uni_pc_order
modules
.
sd_models
.
reload_model_weights
()
modules
.
sd_vae
.
reload_vae_weights
()
...
...
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