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
5ba04f9e
Unverified
Commit
5ba04f9e
authored
Dec 21, 2022
by
Nicolas Patry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Attempting to solve slow loads for `safetensors`.
Fixes #5893
parent
4af3ca53
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
sd_models.py
modules/sd_models.py
+4
-1
No files found.
modules/sd_models.py
View file @
5ba04f9e
...
@@ -168,7 +168,10 @@ def get_state_dict_from_checkpoint(pl_sd):
...
@@ -168,7 +168,10 @@ def get_state_dict_from_checkpoint(pl_sd):
def
read_state_dict
(
checkpoint_file
,
print_global_state
=
False
,
map_location
=
None
):
def
read_state_dict
(
checkpoint_file
,
print_global_state
=
False
,
map_location
=
None
):
_
,
extension
=
os
.
path
.
splitext
(
checkpoint_file
)
_
,
extension
=
os
.
path
.
splitext
(
checkpoint_file
)
if
extension
.
lower
()
==
".safetensors"
:
if
extension
.
lower
()
==
".safetensors"
:
pl_sd
=
safetensors
.
torch
.
load_file
(
checkpoint_file
,
device
=
map_location
or
shared
.
weight_load_location
)
device
=
map_location
or
shared
.
weight_load_location
if
device
is
None
:
device
=
"cuda:0"
if
torch
.
cuda
.
is_available
()
else
"cpu"
pl_sd
=
safetensors
.
torch
.
load_file
(
checkpoint_file
,
device
=
device
)
else
:
else
:
pl_sd
=
torch
.
load
(
checkpoint_file
,
map_location
=
map_location
or
shared
.
weight_load_location
)
pl_sd
=
torch
.
load
(
checkpoint_file
,
map_location
=
map_location
or
shared
.
weight_load_location
)
...
...
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