Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
9feb034e
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
大约 1 年 前同步成功
通知
1785
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
提交
9feb034e
编写于
12月 21, 2023
作者:
W
wangqyqq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support for sdxl-inpaint model
上级
cf2772fa
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
127 addition
and
1 deletion
+127
-1
configs/sd_xl_inpaint.yaml
configs/sd_xl_inpaint.yaml
+98
-0
modules/processing.py
modules/processing.py
+19
-0
modules/sd_models_config.py
modules/sd_models_config.py
+5
-1
modules/sd_models_xl.py
modules/sd_models_xl.py
+5
-0
未找到文件。
configs/sd_xl_inpaint.yaml
0 → 100644
浏览文件 @
9feb034e
model
:
target
:
sgm.models.diffusion.DiffusionEngine
params
:
scale_factor
:
0.13025
disable_first_stage_autocast
:
True
denoiser_config
:
target
:
sgm.modules.diffusionmodules.denoiser.DiscreteDenoiser
params
:
num_idx
:
1000
weighting_config
:
target
:
sgm.modules.diffusionmodules.denoiser_weighting.EpsWeighting
scaling_config
:
target
:
sgm.modules.diffusionmodules.denoiser_scaling.EpsScaling
discretization_config
:
target
:
sgm.modules.diffusionmodules.discretizer.LegacyDDPMDiscretization
network_config
:
target
:
sgm.modules.diffusionmodules.openaimodel.UNetModel
params
:
adm_in_channels
:
2816
num_classes
:
sequential
use_checkpoint
:
True
in_channels
:
9
out_channels
:
4
model_channels
:
320
attention_resolutions
:
[
4
,
2
]
num_res_blocks
:
2
channel_mult
:
[
1
,
2
,
4
]
num_head_channels
:
64
use_spatial_transformer
:
True
use_linear_in_transformer
:
True
transformer_depth
:
[
1
,
2
,
10
]
# note: the first is unused (due to attn_res starting at 2) 32, 16, 8 --> 64, 32, 16
context_dim
:
2048
spatial_transformer_attn_type
:
softmax-xformers
legacy
:
False
conditioner_config
:
target
:
sgm.modules.GeneralConditioner
params
:
emb_models
:
# crossattn cond
-
is_trainable
:
False
input_key
:
txt
target
:
sgm.modules.encoders.modules.FrozenCLIPEmbedder
params
:
layer
:
hidden
layer_idx
:
11
# crossattn and vector cond
-
is_trainable
:
False
input_key
:
txt
target
:
sgm.modules.encoders.modules.FrozenOpenCLIPEmbedder2
params
:
arch
:
ViT-bigG-14
version
:
laion2b_s39b_b160k
freeze
:
True
layer
:
penultimate
always_return_pooled
:
True
legacy
:
False
# vector cond
-
is_trainable
:
False
input_key
:
original_size_as_tuple
target
:
sgm.modules.encoders.modules.ConcatTimestepEmbedderND
params
:
outdim
:
256
# multiplied by two
# vector cond
-
is_trainable
:
False
input_key
:
crop_coords_top_left
target
:
sgm.modules.encoders.modules.ConcatTimestepEmbedderND
params
:
outdim
:
256
# multiplied by two
# vector cond
-
is_trainable
:
False
input_key
:
target_size_as_tuple
target
:
sgm.modules.encoders.modules.ConcatTimestepEmbedderND
params
:
outdim
:
256
# multiplied by two
first_stage_config
:
target
:
sgm.models.autoencoder.AutoencoderKLInferenceWrapper
params
:
embed_dim
:
4
monitor
:
val/rec_loss
ddconfig
:
attn_type
:
vanilla-xformers
double_z
:
true
z_channels
:
4
resolution
:
256
in_channels
:
3
out_ch
:
3
ch
:
128
ch_mult
:
[
1
,
2
,
4
,
4
]
num_res_blocks
:
2
attn_resolutions
:
[]
dropout
:
0.0
lossconfig
:
target
:
torch.nn.Identity
modules/processing.py
浏览文件 @
9feb034e
...
...
@@ -106,6 +106,20 @@ def txt2img_image_conditioning(sd_model, x, width, height):
return
x
.
new_zeros
(
x
.
shape
[
0
],
2
*
sd_model
.
noise_augmentor
.
time_embed
.
dim
,
dtype
=
x
.
dtype
,
device
=
x
.
device
)
else
:
sd
=
sd_model
.
model
.
state_dict
()
diffusion_model_input
=
sd
.
get
(
'diffusion_model.input_blocks.0.0.weight'
,
None
)
if
diffusion_model_input
.
shape
[
1
]
==
9
:
# The "masked-image" in this case will just be all 0.5 since the entire image is masked.
image_conditioning
=
torch
.
ones
(
x
.
shape
[
0
],
3
,
height
,
width
,
device
=
x
.
device
)
*
0.5
image_conditioning
=
images_tensor_to_samples
(
image_conditioning
,
approximation_indexes
.
get
(
opts
.
sd_vae_encode_method
))
# Add the fake full 1s mask to the first dimension.
image_conditioning
=
torch
.
nn
.
functional
.
pad
(
image_conditioning
,
(
0
,
0
,
0
,
0
,
1
,
0
),
value
=
1.0
)
image_conditioning
=
image_conditioning
.
to
(
x
.
dtype
)
return
image_conditioning
# Dummy zero conditioning if we're not using inpainting or unclip models.
# Still takes up a bit of memory, but no encoder call.
# Pretty sure we can just make this a 1x1 image since its not going to be used besides its batch size.
...
...
@@ -362,6 +376,11 @@ class StableDiffusionProcessing:
if
self
.
sampler
.
conditioning_key
==
"crossattn-adm"
:
return
self
.
unclip_image_conditioning
(
source_image
)
sd
=
self
.
sampler
.
model_wrap
.
inner_model
.
model
.
state_dict
()
diffusion_model_input
=
sd
.
get
(
'diffusion_model.input_blocks.0.0.weight'
,
None
)
if
diffusion_model_input
.
shape
[
1
]
==
9
:
return
self
.
inpainting_image_conditioning
(
source_image
,
latent_image
,
image_mask
=
image_mask
)
# Dummy zero conditioning if we're not using inpainting or depth model.
return
latent_image
.
new_zeros
(
latent_image
.
shape
[
0
],
5
,
1
,
1
)
...
...
modules/sd_models_config.py
浏览文件 @
9feb034e
...
...
@@ -15,6 +15,7 @@ config_sd2v = os.path.join(sd_repo_configs_path, "v2-inference-v.yaml")
config_sd2_inpainting
=
os
.
path
.
join
(
sd_repo_configs_path
,
"v2-inpainting-inference.yaml"
)
config_sdxl
=
os
.
path
.
join
(
sd_xl_repo_configs_path
,
"sd_xl_base.yaml"
)
config_sdxl_refiner
=
os
.
path
.
join
(
sd_xl_repo_configs_path
,
"sd_xl_refiner.yaml"
)
config_sdxl_inpainting
=
os
.
path
.
join
(
sd_configs_path
,
"sd_xl_inpaint.yaml"
)
config_depth_model
=
os
.
path
.
join
(
sd_repo_configs_path
,
"v2-midas-inference.yaml"
)
config_unclip
=
os
.
path
.
join
(
sd_repo_configs_path
,
"v2-1-stable-unclip-l-inference.yaml"
)
config_unopenclip
=
os
.
path
.
join
(
sd_repo_configs_path
,
"v2-1-stable-unclip-h-inference.yaml"
)
...
...
@@ -71,7 +72,10 @@ def guess_model_config_from_state_dict(sd, filename):
sd2_variations_weight
=
sd
.
get
(
'embedder.model.ln_final.weight'
,
None
)
if
sd
.
get
(
'conditioner.embedders.1.model.ln_final.weight'
,
None
)
is
not
None
:
return
config_sdxl
if
diffusion_model_input
.
shape
[
1
]
==
9
:
return
config_sdxl_inpainting
else
:
return
config_sdxl
if
sd
.
get
(
'conditioner.embedders.0.model.ln_final.weight'
,
None
)
is
not
None
:
return
config_sdxl_refiner
elif
sd
.
get
(
'depth_model.model.pretrained.act_postprocess3.0.project.0.bias'
,
None
)
is
not
None
:
...
...
modules/sd_models_xl.py
浏览文件 @
9feb034e
...
...
@@ -34,6 +34,11 @@ def get_learned_conditioning(self: sgm.models.diffusion.DiffusionEngine, batch:
def
apply_model
(
self
:
sgm
.
models
.
diffusion
.
DiffusionEngine
,
x
,
t
,
cond
):
sd
=
self
.
model
.
state_dict
()
diffusion_model_input
=
sd
.
get
(
'diffusion_model.input_blocks.0.0.weight'
,
None
)
if
diffusion_model_input
.
shape
[
1
]
==
9
:
x
=
torch
.
cat
([
x
]
+
cond
[
'c_concat'
],
dim
=
1
)
return
self
.
model
(
x
,
t
,
cond
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录