Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
042e1d5d
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,发现更多精彩内容 >>
提交
042e1d5d
编写于
8月 20, 2023
作者:
U
Uminosachi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix SD VAE switch error after model reuse
上级
9d2299ed
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
2 deletion
+20
-2
modules/sd_models.py
modules/sd_models.py
+20
-2
未找到文件。
modules/sd_models.py
浏览文件 @
042e1d5d
...
...
@@ -462,6 +462,7 @@ class SdModelData:
def
__init__
(
self
):
self
.
sd_model
=
None
self
.
loaded_sd_models
=
[]
self
.
loaded_vae_states
=
{}
self
.
was_loaded_at_least_once
=
False
self
.
lock
=
threading
.
Lock
()
...
...
@@ -485,16 +486,27 @@ 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_state
=
self
.
loaded_vae_states
.
get
(
v
.
sd_model_hash
,
{})
sd_vae
.
base_vae
=
sd_vae_state
.
get
(
"base_vae"
,
None
)
sd_vae
.
loaded_vae_file
=
sd_vae_state
.
get
(
"loaded_vae_file"
,
None
)
sd_vae
.
checkpoint_info
=
sd_vae_state
.
get
(
"checkpoint_info"
,
None
)
try
:
self
.
loaded_sd_models
.
remove
(
v
)
self
.
loaded_vae_states
.
pop
(
v
.
sd_model_hash
,
{}).
clear
()
except
ValueError
:
pass
if
v
is
not
None
:
self
.
loaded_sd_models
.
insert
(
0
,
v
)
self
.
loaded_vae_states
[
v
.
sd_model_hash
]
=
dict
(
base_vae
=
sd_vae
.
base_vae
,
loaded_vae_file
=
sd_vae
.
loaded_vae_file
,
checkpoint_info
=
sd_vae
.
checkpoint_info
,
)
model_data
=
SdModelData
()
...
...
@@ -649,6 +661,7 @@ def reuse_model_from_already_loaded(sd_model, checkpoint_info, timer):
if
len
(
model_data
.
loaded_sd_models
)
>
shared
.
opts
.
sd_checkpoints_limit
>
0
:
print
(
f
"Unloading model
{
len
(
model_data
.
loaded_sd_models
)
}
over the limit of
{
shared
.
opts
.
sd_checkpoints_limit
}
:
{
loaded_model
.
sd_checkpoint_info
.
title
}
"
)
model_data
.
loaded_sd_models
.
pop
()
model_data
.
loaded_vae_states
.
pop
(
loaded_model
.
sd_model_hash
,
{}).
clear
()
send_model_to_trash
(
loaded_model
)
timer
.
record
(
"send model to trash"
)
...
...
@@ -660,7 +673,7 @@ 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
...
...
@@ -678,6 +691,11 @@ 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_state
=
model_data
.
loaded_vae_states
.
pop
(
sd_model
.
sd_model_hash
,
{})
sd_vae
.
base_vae
=
sd_vae_state
.
get
(
"base_vae"
,
None
)
sd_vae
.
loaded_vae_file
=
sd_vae_state
.
get
(
"loaded_vae_file"
,
None
)
sd_vae
.
checkpoint_info
=
sd_vae_state
.
get
(
"checkpoint_info"
,
None
)
print
(
f
"Reusing loaded model
{
sd_model
.
sd_checkpoint_info
.
title
}
to load
{
checkpoint_info
.
title
}
"
)
return
sd_model
else
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录