Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
bf7a6998
Commit
bf7a6998
authored
Oct 31, 2022
by
Muhammad Rizqi Nur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #4035 for real now
parent
36966e32
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
sd_models.py
modules/sd_models.py
+7
-6
No files found.
modules/sd_models.py
View file @
bf7a6998
...
@@ -165,6 +165,9 @@ def load_model_weights(model, checkpoint_info):
...
@@ -165,6 +165,9 @@ def load_model_weights(model, checkpoint_info):
checkpoint_file
=
checkpoint_info
.
filename
checkpoint_file
=
checkpoint_info
.
filename
sd_model_hash
=
checkpoint_info
.
hash
sd_model_hash
=
checkpoint_info
.
hash
if
shared
.
opts
.
sd_checkpoint_cache
>
0
and
hasattr
(
model
,
"sd_checkpoint_info"
):
checkpoints_loaded
[
model
.
sd_checkpoint_info
]
=
model
.
state_dict
()
.
copy
()
if
checkpoint_info
not
in
checkpoints_loaded
:
if
checkpoint_info
not
in
checkpoints_loaded
:
print
(
f
"Loading weights [{sd_model_hash}] from {checkpoint_file}"
)
print
(
f
"Loading weights [{sd_model_hash}] from {checkpoint_file}"
)
...
@@ -198,16 +201,14 @@ def load_model_weights(model, checkpoint_info):
...
@@ -198,16 +201,14 @@ def load_model_weights(model, checkpoint_info):
model
.
first_stage_model
.
load_state_dict
(
vae_dict
)
model
.
first_stage_model
.
load_state_dict
(
vae_dict
)
model
.
first_stage_model
.
to
(
devices
.
dtype_vae
)
model
.
first_stage_model
.
to
(
devices
.
dtype_vae
)
if
shared
.
opts
.
sd_checkpoint_cache
>
0
:
checkpoints_loaded
[
checkpoint_info
]
=
model
.
state_dict
()
.
copy
()
while
len
(
checkpoints_loaded
)
>
shared
.
opts
.
sd_checkpoint_cache
+
1
:
checkpoints_loaded
.
popitem
(
last
=
False
)
# LRU
else
:
else
:
print
(
f
"Loading weights [{sd_model_hash}] from cache"
)
print
(
f
"Loading weights [{sd_model_hash}] from cache"
)
checkpoints_loaded
.
move_to_end
(
checkpoint_info
)
model
.
load_state_dict
(
checkpoints_loaded
[
checkpoint_info
])
model
.
load_state_dict
(
checkpoints_loaded
[
checkpoint_info
])
if
shared
.
opts
.
sd_checkpoint_cache
>
0
:
while
len
(
checkpoints_loaded
)
>
shared
.
opts
.
sd_checkpoint_cache
:
checkpoints_loaded
.
popitem
(
last
=
False
)
# LRU
model
.
sd_model_hash
=
sd_model_hash
model
.
sd_model_hash
=
sd_model_hash
model
.
sd_model_checkpoint
=
checkpoint_file
model
.
sd_model_checkpoint
=
checkpoint_file
model
.
sd_checkpoint_info
=
checkpoint_info
model
.
sd_checkpoint_info
=
checkpoint_info
...
...
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