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
f108782e
Unverified
Commit
f108782e
authored
Nov 27, 2022
by
AUTOMATIC1111
Committed by
GitHub
Nov 27, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4930 from Narsil/allow_to_load_safetensors_file
Supporting `*.safetensors` format.
parents
a89d7f4f
0efffbb4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
sd_models.py
modules/sd_models.py
+9
-2
No files found.
modules/sd_models.py
View file @
f108782e
...
@@ -45,7 +45,7 @@ def checkpoint_tiles():
...
@@ -45,7 +45,7 @@ def checkpoint_tiles():
def
list_models
():
def
list_models
():
checkpoints_list
.
clear
()
checkpoints_list
.
clear
()
model_list
=
modelloader
.
load_models
(
model_path
=
model_path
,
command_path
=
shared
.
cmd_opts
.
ckpt_dir
,
ext_filter
=
[
".ckpt"
])
model_list
=
modelloader
.
load_models
(
model_path
=
model_path
,
command_path
=
shared
.
cmd_opts
.
ckpt_dir
,
ext_filter
=
[
".ckpt"
,
".safetensors"
])
def
modeltitle
(
path
,
shorthash
):
def
modeltitle
(
path
,
shorthash
):
abspath
=
os
.
path
.
abspath
(
path
)
abspath
=
os
.
path
.
abspath
(
path
)
...
@@ -173,7 +173,14 @@ def load_model_weights(model, checkpoint_info, vae_file="auto"):
...
@@ -173,7 +173,14 @@ def load_model_weights(model, checkpoint_info, vae_file="auto"):
# load from file
# load from file
print
(
f
"Loading weights [{sd_model_hash}] from {checkpoint_file}"
)
print
(
f
"Loading weights [{sd_model_hash}] from {checkpoint_file}"
)
pl_sd
=
torch
.
load
(
checkpoint_file
,
map_location
=
shared
.
weight_load_location
)
if
checkpoint_file
.
endswith
(
".safetensors"
):
try
:
from
safetensors.torch
import
load_file
except
ImportError
as
e
:
raise
ImportError
(
f
"The model is in safetensors format and it is not installed, use `pip install safetensors`: {e}"
)
pl_sd
=
load_file
(
checkpoint_file
,
device
=
shared
.
weight_load_location
)
else
:
pl_sd
=
torch
.
load
(
checkpoint_file
,
map_location
=
shared
.
weight_load_location
)
if
"global_step"
in
pl_sd
:
if
"global_step"
in
pl_sd
:
print
(
f
"Global Step: {pl_sd['global_step']}"
)
print
(
f
"Global Step: {pl_sd['global_step']}"
)
...
...
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