Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
5a3fe7a8
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
11 个月 前同步成功
通知
1771
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
5a3fe7a8
编写于
8月 21, 2023
作者:
A
AUTOMATIC1111
提交者:
GitHub
8月 21, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12685 from Uminosachi/fix-vae-mismatch
Fix SD VAE switch error after model reuse
上级
42b72fe2
be301f22
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
3 deletion
+14
-3
modules/sd_models.py
modules/sd_models.py
+11
-2
modules/sd_vae.py
modules/sd_vae.py
+3
-1
未找到文件。
modules/sd_models.py
浏览文件 @
5a3fe7a8
...
...
@@ -485,8 +485,12 @@ class SdModelData:
return
self
.
sd_model
def
set_sd_model
(
self
,
v
):
def
set_sd_model
(
self
,
v
,
already_loaded
=
False
):
self
.
sd_model
=
v
if
already_loaded
:
sd_vae
.
base_vae
=
getattr
(
v
,
"base_vae"
,
None
)
sd_vae
.
loaded_vae_file
=
getattr
(
v
,
"loaded_vae_file"
,
None
)
sd_vae
.
checkpoint_info
=
v
.
sd_checkpoint_info
try
:
self
.
loaded_sd_models
.
remove
(
v
)
...
...
@@ -660,13 +664,14 @@ def reuse_model_from_already_loaded(sd_model, checkpoint_info, timer):
send_model_to_device
(
already_loaded
)
timer
.
record
(
"send model to device"
)
model_data
.
set_sd_model
(
already_loaded
)
model_data
.
set_sd_model
(
already_loaded
,
already_loaded
=
True
)
if
not
SkipWritingToConfig
.
skip
:
shared
.
opts
.
data
[
"sd_model_checkpoint"
]
=
already_loaded
.
sd_checkpoint_info
.
title
shared
.
opts
.
data
[
"sd_checkpoint_hash"
]
=
already_loaded
.
sd_checkpoint_info
.
sha256
print
(
f
"Using already loaded model
{
already_loaded
.
sd_checkpoint_info
.
title
}
: done in
{
timer
.
summary
()
}
"
)
sd_vae
.
reload_vae_weights
(
already_loaded
)
return
model_data
.
sd_model
elif
shared
.
opts
.
sd_checkpoints_limit
>
1
and
len
(
model_data
.
loaded_sd_models
)
<
shared
.
opts
.
sd_checkpoints_limit
:
print
(
f
"Loading model
{
checkpoint_info
.
title
}
(
{
len
(
model_data
.
loaded_sd_models
)
+
1
}
out of
{
shared
.
opts
.
sd_checkpoints_limit
}
)"
)
...
...
@@ -678,6 +683,10 @@ def reuse_model_from_already_loaded(sd_model, checkpoint_info, timer):
sd_model
=
model_data
.
loaded_sd_models
.
pop
()
model_data
.
sd_model
=
sd_model
sd_vae
.
base_vae
=
getattr
(
sd_model
,
"base_vae"
,
None
)
sd_vae
.
loaded_vae_file
=
getattr
(
sd_model
,
"loaded_vae_file"
,
None
)
sd_vae
.
checkpoint_info
=
sd_model
.
sd_checkpoint_info
print
(
f
"Reusing loaded model
{
sd_model
.
sd_checkpoint_info
.
title
}
to load
{
checkpoint_info
.
title
}
"
)
return
sd_model
else
:
...
...
modules/sd_vae.py
浏览文件 @
5a3fe7a8
...
...
@@ -192,7 +192,7 @@ def load_vae_dict(filename, map_location):
def
load_vae
(
model
,
vae_file
=
None
,
vae_source
=
"from unknown source"
):
global
vae_dict
,
loaded_vae_file
global
vae_dict
,
base_vae
,
loaded_vae_file
# save_settings = False
cache_enabled
=
shared
.
opts
.
sd_vae_checkpoint_cache
>
0
...
...
@@ -230,6 +230,8 @@ def load_vae(model, vae_file=None, vae_source="from unknown source"):
restore_base_vae
(
model
)
loaded_vae_file
=
vae_file
model
.
base_vae
=
base_vae
model
.
loaded_vae_file
=
loaded_vae_file
# don't call this from outside
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录