Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
b186045f
Commit
b186045f
authored
May 23, 2023
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
possible fix for empty list of optimizations #10605
parent
3f50b7d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
9 deletions
+29
-9
modules/sd_hijack.py
modules/sd_hijack.py
+15
-6
webui.py
webui.py
+14
-3
No files found.
modules/sd_hijack.py
View file @
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
View file @
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"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment