Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
b186045f
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
10 个月 前同步成功
通知
1740
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b186045f
编写于
5月 23, 2023
作者:
A
AUTOMATIC
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
possible fix for empty list of optimizations #10605
上级
3f50b7d7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
9 deletion
+29
-9
modules/sd_hijack.py
modules/sd_hijack.py
+15
-6
webui.py
webui.py
+14
-3
未找到文件。
modules/sd_hijack.py
浏览文件 @
b186045f
...
...
@@ -48,6 +48,11 @@ def apply_optimizations():
undo_optimizations
()
if
len
(
optimizers
)
==
0
:
# a script can access the model very early, and optimizations would not be filled by then
current_optimizer
=
None
return
''
ldm
.
modules
.
diffusionmodules
.
model
.
nonlinearity
=
silu
ldm
.
modules
.
diffusionmodules
.
openaimodel
.
th
=
sd_hijack_unet
.
th
...
...
@@ -67,8 +72,9 @@ def apply_optimizations():
matching_optimizer
=
optimizers
[
0
]
if
matching_optimizer
is
not
None
:
print
(
f
"Applying optimization:
{
matching_optimizer
.
name
}
"
)
print
(
f
"Applying optimization:
{
matching_optimizer
.
name
}
... "
,
end
=
''
)
matching_optimizer
.
apply
()
print
(
"done."
)
current_optimizer
=
matching_optimizer
return
current_optimizer
.
name
else
:
...
...
@@ -149,6 +155,13 @@ class StableDiffusionModelHijack:
def
__init__
(
self
):
self
.
embedding_db
.
add_embedding_dir
(
cmd_opts
.
embeddings_dir
)
def
apply_optimizations
(
self
):
try
:
self
.
optimization_method
=
apply_optimizations
()
except
Exception
as
e
:
errors
.
display
(
e
,
"applying cross attention optimization"
)
undo_optimizations
()
def
hijack
(
self
,
m
):
if
type
(
m
.
cond_stage_model
)
==
xlmr
.
BertSeriesModelWithTransformation
:
model_embeddings
=
m
.
cond_stage_model
.
roberta
.
embeddings
...
...
@@ -168,11 +181,7 @@ class StableDiffusionModelHijack:
if
m
.
cond_stage_key
==
"edit"
:
sd_hijack_unet
.
hijack_ddpm_edit
()
try
:
self
.
optimization_method
=
apply_optimizations
()
except
Exception
as
e
:
errors
.
display
(
e
,
"applying cross attention optimization"
)
undo_optimizations
()
self
.
apply_optimizations
()
self
.
clip
=
m
.
cond_stage_model
...
...
webui.py
浏览文件 @
b186045f
...
...
@@ -291,9 +291,20 @@ def initialize_rest(*, reload_script_modules=False):
modules
.
sd_hijack
.
list_optimizers
()
startup_timer
.
record
(
"scripts list_optimizers"
)
# load model in parallel to other startup stuff
# (when reloading, this does nothing)
Thread
(
target
=
lambda
:
shared
.
sd_model
).
start
()
def
load_model
():
"""
Accesses shared.sd_model property to load model.
After it's available, if it has been loaded before this access by some extension,
its optimization may be None because the list of optimizaers has neet been filled
by that time, so we apply optimization again.
"""
shared
.
sd_model
# noqa: B018
if
modules
.
sd_hijack
.
current_optimizer
is
None
:
modules
.
sd_hijack
.
apply_optimizations
()
Thread
(
target
=
load_model
).
start
()
shared
.
reload_hypernetworks
()
startup_timer
.
record
(
"reload hypernetworks"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录