Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
42082e8a
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
10 个月 前同步成功
通知
1736
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
42082e8a
编写于
3月 28, 2023
作者:
D
devdn
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
performance increase
上级
3856ada5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
6 deletion
+22
-6
modules/processing.py
modules/processing.py
+3
-1
modules/sd_samplers_kdiffusion.py
modules/sd_samplers_kdiffusion.py
+17
-5
modules/shared.py
modules/shared.py
+1
-0
scripts/xyz_grid.py
scripts/xyz_grid.py
+1
-0
未找到文件。
modules/processing.py
浏览文件 @
42082e8a
...
...
@@ -105,7 +105,7 @@ class StableDiffusionProcessing:
"""
The first set of paramaters: sd_models -> do_not_reload_embeddings represent the minimum required to create a StableDiffusionProcessing
"""
def
__init__
(
self
,
sd_model
=
None
,
outpath_samples
=
None
,
outpath_grids
=
None
,
prompt
:
str
=
""
,
styles
:
List
[
str
]
=
None
,
seed
:
int
=
-
1
,
subseed
:
int
=
-
1
,
subseed_strength
:
float
=
0
,
seed_resize_from_h
:
int
=
-
1
,
seed_resize_from_w
:
int
=
-
1
,
seed_enable_extras
:
bool
=
True
,
sampler_name
:
str
=
None
,
batch_size
:
int
=
1
,
n_iter
:
int
=
1
,
steps
:
int
=
50
,
cfg_scale
:
float
=
7.0
,
width
:
int
=
512
,
height
:
int
=
512
,
restore_faces
:
bool
=
False
,
tiling
:
bool
=
False
,
do_not_save_samples
:
bool
=
False
,
do_not_save_grid
:
bool
=
False
,
extra_generation_params
:
Dict
[
Any
,
Any
]
=
None
,
overlay_images
:
Any
=
None
,
negative_prompt
:
str
=
None
,
eta
:
float
=
None
,
do_not_reload_embeddings
:
bool
=
False
,
denoising_strength
:
float
=
0
,
ddim_discretize
:
str
=
None
,
s_churn
:
float
=
0.0
,
s_tmax
:
float
=
None
,
s_tmin
:
float
=
0.0
,
s_noise
:
float
=
1.0
,
override_settings
:
Dict
[
str
,
Any
]
=
None
,
override_settings_restore_afterwards
:
bool
=
True
,
sampler_index
:
int
=
None
,
script_args
:
list
=
None
):
def
__init__
(
self
,
sd_model
=
None
,
outpath_samples
=
None
,
outpath_grids
=
None
,
prompt
:
str
=
""
,
styles
:
List
[
str
]
=
None
,
seed
:
int
=
-
1
,
subseed
:
int
=
-
1
,
subseed_strength
:
float
=
0
,
seed_resize_from_h
:
int
=
-
1
,
seed_resize_from_w
:
int
=
-
1
,
seed_enable_extras
:
bool
=
True
,
sampler_name
:
str
=
None
,
batch_size
:
int
=
1
,
n_iter
:
int
=
1
,
steps
:
int
=
50
,
cfg_scale
:
float
=
7.0
,
width
:
int
=
512
,
height
:
int
=
512
,
restore_faces
:
bool
=
False
,
tiling
:
bool
=
False
,
do_not_save_samples
:
bool
=
False
,
do_not_save_grid
:
bool
=
False
,
extra_generation_params
:
Dict
[
Any
,
Any
]
=
None
,
overlay_images
:
Any
=
None
,
negative_prompt
:
str
=
None
,
eta
:
float
=
None
,
do_not_reload_embeddings
:
bool
=
False
,
denoising_strength
:
float
=
0
,
ddim_discretize
:
str
=
None
,
s_
min_uncond
:
float
=
0.0
,
s_
churn
:
float
=
0.0
,
s_tmax
:
float
=
None
,
s_tmin
:
float
=
0.0
,
s_noise
:
float
=
1.0
,
override_settings
:
Dict
[
str
,
Any
]
=
None
,
override_settings_restore_afterwards
:
bool
=
True
,
sampler_index
:
int
=
None
,
script_args
:
list
=
None
):
if
sampler_index
is
not
None
:
print
(
"sampler_index argument for StableDiffusionProcessing does not do anything; use sampler_name"
,
file
=
sys
.
stderr
)
...
...
@@ -140,6 +140,7 @@ class StableDiffusionProcessing:
self
.
denoising_strength
:
float
=
denoising_strength
self
.
sampler_noise_scheduler_override
=
None
self
.
ddim_discretize
=
ddim_discretize
or
opts
.
ddim_discretize
self
.
s_min_uncond
=
s_min_uncond
or
opts
.
s_min_uncond
self
.
s_churn
=
s_churn
or
opts
.
s_churn
self
.
s_tmin
=
s_tmin
or
opts
.
s_tmin
self
.
s_tmax
=
s_tmax
or
float
(
'inf'
)
# not representable as a standard ui option
...
...
@@ -162,6 +163,7 @@ class StableDiffusionProcessing:
self
.
all_seeds
=
None
self
.
all_subseeds
=
None
self
.
iteration
=
0
@
property
def
sd_model
(
self
):
...
...
modules/sd_samplers_kdiffusion.py
浏览文件 @
42082e8a
...
...
@@ -76,7 +76,7 @@ class CFGDenoiser(torch.nn.Module):
return
denoised
def
forward
(
self
,
x
,
sigma
,
uncond
,
cond
,
cond_scale
,
image_cond
):
def
forward
(
self
,
x
,
sigma
,
uncond
,
cond
,
cond_scale
,
s_min_uncond
,
image_cond
):
if
state
.
interrupted
or
state
.
skipped
:
raise
sd_samplers_common
.
InterruptedException
...
...
@@ -116,6 +116,12 @@ class CFGDenoiser(torch.nn.Module):
tensor
=
denoiser_params
.
text_cond
uncond
=
denoiser_params
.
text_uncond
sigma_thresh
=
s_min_uncond
if
(
torch
.
dot
(
sigma
,
sigma
)
<
sigma
.
shape
[
0
]
*
(
sigma_thresh
*
sigma_thresh
)
and
not
is_edit_model
):
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
not
is_edit_model
:
cond_in
=
torch
.
cat
([
tensor
,
uncond
])
...
...
@@ -144,7 +150,8 @@ class CFGDenoiser(torch.nn.Module):
x_out
[
a
:
b
]
=
self
.
inner_model
(
x_in
[
a
:
b
],
sigma_in
[
a
:
b
],
cond
=
make_condition_dict
(
c_crossattn
,
image_cond_in
[
a
:
b
]))
x_out
[
-
uncond
.
shape
[
0
]:]
=
self
.
inner_model
(
x_in
[
-
uncond
.
shape
[
0
]:],
sigma_in
[
-
uncond
.
shape
[
0
]:],
cond
=
make_condition_dict
([
uncond
],
image_cond_in
[
-
uncond
.
shape
[
0
]:]))
if
uncond
.
shape
[
0
]:
x_out
[
-
uncond
.
shape
[
0
]:]
=
self
.
inner_model
(
x_in
[
-
uncond
.
shape
[
0
]:],
sigma_in
[
-
uncond
.
shape
[
0
]:],
cond
=
make_condition_dict
([
uncond
],
image_cond_in
[
-
uncond
.
shape
[
0
]:]))
denoised_params
=
CFGDenoisedParams
(
x_out
,
state
.
sampling_step
,
state
.
sampling_steps
)
cfg_denoised_callback
(
denoised_params
)
...
...
@@ -157,7 +164,10 @@ class CFGDenoiser(torch.nn.Module):
sd_samplers_common
.
store_latent
(
x_out
[
-
uncond
.
shape
[
0
]:])
if
not
is_edit_model
:
denoised
=
self
.
combine_denoised
(
x_out
,
conds_list
,
uncond
,
cond_scale
)
if
uncond
.
shape
[
0
]:
denoised
=
self
.
combine_denoised
(
x_out
,
conds_list
,
uncond
,
cond_scale
)
else
:
denoised
=
x_out
else
:
denoised
=
self
.
combine_denoised_for_edit_model
(
x_out
,
cond_scale
)
...
...
@@ -165,7 +175,6 @@ class CFGDenoiser(torch.nn.Module):
denoised
=
self
.
init_latent
*
self
.
mask
+
self
.
nmask
*
denoised
self
.
step
+=
1
return
denoised
...
...
@@ -244,6 +253,7 @@ class KDiffusionSampler:
self
.
model_wrap_cfg
.
step
=
0
self
.
model_wrap_cfg
.
image_cfg_scale
=
getattr
(
p
,
'image_cfg_scale'
,
None
)
self
.
eta
=
p
.
eta
if
p
.
eta
is
not
None
else
opts
.
eta_ancestral
self
.
s_min_uncond
=
getattr
(
p
,
's_min_uncond'
,
0.0
)
k_diffusion
.
sampling
.
torch
=
TorchHijack
(
self
.
sampler_noises
if
self
.
sampler_noises
is
not
None
else
[])
...
...
@@ -326,6 +336,7 @@ class KDiffusionSampler:
'image_cond'
:
image_conditioning
,
'uncond'
:
unconditional_conditioning
,
'cond_scale'
:
p
.
cfg_scale
,
's_min_uncond'
:
self
.
s_min_uncond
}
samples
=
self
.
launch_sampling
(
t_enc
+
1
,
lambda
:
self
.
func
(
self
.
model_wrap_cfg
,
xi
,
extra_args
=
extra_args
,
disable
=
False
,
callback
=
self
.
callback_state
,
**
extra_params_kwargs
))
...
...
@@ -359,7 +370,8 @@ class KDiffusionSampler:
'cond'
:
conditioning
,
'image_cond'
:
image_conditioning
,
'uncond'
:
unconditional_conditioning
,
'cond_scale'
:
p
.
cfg_scale
'cond_scale'
:
p
.
cfg_scale
,
's_min_uncond'
:
self
.
s_min_uncond
},
disable
=
False
,
callback
=
self
.
callback_state
,
**
extra_params_kwargs
))
return
samples
...
...
modules/shared.py
浏览文件 @
42082e8a
...
...
@@ -405,6 +405,7 @@ options_templates.update(options_section(('sampler-params', "Sampler parameters"
"eta_ancestral"
:
OptionInfo
(
1.0
,
"eta (noise multiplier) for ancestral samplers"
,
gr
.
Slider
,
{
"minimum"
:
0.0
,
"maximum"
:
1.0
,
"step"
:
0.01
}),
"ddim_discretize"
:
OptionInfo
(
'uniform'
,
"img2img DDIM discretize"
,
gr
.
Radio
,
{
"choices"
:
[
'uniform'
,
'quad'
]}),
's_churn'
:
OptionInfo
(
0.0
,
"sigma churn"
,
gr
.
Slider
,
{
"minimum"
:
0.0
,
"maximum"
:
1.0
,
"step"
:
0.01
}),
's_min_uncond'
:
OptionInfo
(
0
,
"minimum sigma to use unconditioned guidance"
,
gr
.
Slider
,
{
"minimum"
:
0.0
,
"maximum"
:
2.0
,
"step"
:
0.01
}),
's_tmin'
:
OptionInfo
(
0.0
,
"sigma tmin"
,
gr
.
Slider
,
{
"minimum"
:
0.0
,
"maximum"
:
1.0
,
"step"
:
0.01
}),
'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
}),
...
...
scripts/xyz_grid.py
浏览文件 @
42082e8a
...
...
@@ -212,6 +212,7 @@ axis_options = [
AxisOptionTxt2Img
(
"Sampler"
,
str
,
apply_sampler
,
format_value
=
format_value
,
confirm
=
confirm_samplers
,
choices
=
lambda
:
[
x
.
name
for
x
in
sd_samplers
.
samplers
]),
AxisOptionImg2Img
(
"Sampler"
,
str
,
apply_sampler
,
format_value
=
format_value
,
confirm
=
confirm_samplers
,
choices
=
lambda
:
[
x
.
name
for
x
in
sd_samplers
.
samplers_for_img2img
]),
AxisOption
(
"Checkpoint name"
,
str
,
apply_checkpoint
,
format_value
=
format_value
,
confirm
=
confirm_checkpoints
,
cost
=
1.0
,
choices
=
lambda
:
list
(
sd_models
.
checkpoints_list
)),
AxisOption
(
"Negative Guidance minimum sigma"
,
float
,
apply_field
(
"s_min_uncond"
)),
AxisOption
(
"Sigma Churn"
,
float
,
apply_field
(
"s_churn"
)),
AxisOption
(
"Sigma min"
,
float
,
apply_field
(
"s_tmin"
)),
AxisOption
(
"Sigma max"
,
float
,
apply_field
(
"s_tmax"
)),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录