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
30461bef
Commit
30461bef
authored
Jun 08, 2024
by
AUTOMATIC1111
Committed by
GitHub
Jun 08, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15602 from AUTOMATIC1111/initial-model-download-integrity
Initial model download integrity
parents
569f17c6
c69773d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
+8
-4
modules/modelloader.py
modules/modelloader.py
+5
-3
modules/sd_models.py
modules/sd_models.py
+3
-1
No files found.
modules/modelloader.py
View file @
30461bef
...
@@ -23,6 +23,7 @@ def load_file_from_url(
...
@@ -23,6 +23,7 @@ def load_file_from_url(
model_dir
:
str
,
model_dir
:
str
,
progress
:
bool
=
True
,
progress
:
bool
=
True
,
file_name
:
str
|
None
=
None
,
file_name
:
str
|
None
=
None
,
hash_prefix
:
str
|
None
=
None
,
)
->
str
:
)
->
str
:
"""Download a file from `url` into `model_dir`, using the file present if possible.
"""Download a file from `url` into `model_dir`, using the file present if possible.
...
@@ -36,11 +37,11 @@ def load_file_from_url(
...
@@ -36,11 +37,11 @@ def load_file_from_url(
if
not
os
.
path
.
exists
(
cached_file
):
if
not
os
.
path
.
exists
(
cached_file
):
print
(
f
'Downloading: "{url}" to {cached_file}
\n
'
)
print
(
f
'Downloading: "{url}" to {cached_file}
\n
'
)
from
torch.hub
import
download_url_to_file
from
torch.hub
import
download_url_to_file
download_url_to_file
(
url
,
cached_file
,
progress
=
progress
)
download_url_to_file
(
url
,
cached_file
,
progress
=
progress
,
hash_prefix
=
hash_prefix
)
return
cached_file
return
cached_file
def
load_models
(
model_path
:
str
,
model_url
:
str
=
None
,
command_path
:
str
=
None
,
ext_filter
=
None
,
download_name
=
None
,
ext_blacklist
=
None
)
->
list
:
def
load_models
(
model_path
:
str
,
model_url
:
str
=
None
,
command_path
:
str
=
None
,
ext_filter
=
None
,
download_name
=
None
,
ext_blacklist
=
None
,
hash_prefix
=
None
)
->
list
:
"""
"""
A one-and done loader to try finding the desired models in specified directories.
A one-and done loader to try finding the desired models in specified directories.
...
@@ -49,6 +50,7 @@ def load_models(model_path: str, model_url: str = None, command_path: str = None
...
@@ -49,6 +50,7 @@ def load_models(model_path: str, model_url: str = None, command_path: str = None
@param model_path: The location to store/find models in.
@param model_path: The location to store/find models in.
@param command_path: A command-line argument to search for models in first.
@param command_path: A command-line argument to search for models in first.
@param ext_filter: An optional list of filename extensions to filter by
@param ext_filter: An optional list of filename extensions to filter by
@param hash_prefix: the expected sha256 of the model_url
@return: A list of paths containing the desired model(s)
@return: A list of paths containing the desired model(s)
"""
"""
output
=
[]
output
=
[]
...
@@ -78,7 +80,7 @@ def load_models(model_path: str, model_url: str = None, command_path: str = None
...
@@ -78,7 +80,7 @@ def load_models(model_path: str, model_url: str = None, command_path: str = None
if
model_url
is
not
None
and
len
(
output
)
==
0
:
if
model_url
is
not
None
and
len
(
output
)
==
0
:
if
download_name
is
not
None
:
if
download_name
is
not
None
:
output
.
append
(
load_file_from_url
(
model_url
,
model_dir
=
places
[
0
],
file_name
=
download_name
))
output
.
append
(
load_file_from_url
(
model_url
,
model_dir
=
places
[
0
],
file_name
=
download_name
,
hash_prefix
=
hash_prefix
))
else
:
else
:
output
.
append
(
model_url
)
output
.
append
(
model_url
)
...
...
modules/sd_models.py
View file @
30461bef
...
@@ -149,10 +149,12 @@ def list_models():
...
@@ -149,10 +149,12 @@ def list_models():
cmd_ckpt
=
shared
.
cmd_opts
.
ckpt
cmd_ckpt
=
shared
.
cmd_opts
.
ckpt
if
shared
.
cmd_opts
.
no_download_sd_model
or
cmd_ckpt
!=
shared
.
sd_model_file
or
os
.
path
.
exists
(
cmd_ckpt
):
if
shared
.
cmd_opts
.
no_download_sd_model
or
cmd_ckpt
!=
shared
.
sd_model_file
or
os
.
path
.
exists
(
cmd_ckpt
):
model_url
=
None
model_url
=
None
expected_sha256
=
None
else
:
else
:
model_url
=
f
"{shared.hf_endpoint}/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors"
model_url
=
f
"{shared.hf_endpoint}/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors"
expected_sha256
=
'6ce0161689b3853acaa03779ec93eafe75a02f4ced659bee03f50797806fa2fa'
model_list
=
modelloader
.
load_models
(
model_path
=
model_path
,
model_url
=
model_url
,
command_path
=
shared
.
cmd_opts
.
ckpt_dir
,
ext_filter
=
[
".ckpt"
,
".safetensors"
],
download_name
=
"v1-5-pruned-emaonly.safetensors"
,
ext_blacklist
=
[
".vae.ckpt"
,
".vae.safetensors"
])
model_list
=
modelloader
.
load_models
(
model_path
=
model_path
,
model_url
=
model_url
,
command_path
=
shared
.
cmd_opts
.
ckpt_dir
,
ext_filter
=
[
".ckpt"
,
".safetensors"
],
download_name
=
"v1-5-pruned-emaonly.safetensors"
,
ext_blacklist
=
[
".vae.ckpt"
,
".vae.safetensors"
]
,
hash_prefix
=
expected_sha256
)
if
os
.
path
.
exists
(
cmd_ckpt
):
if
os
.
path
.
exists
(
cmd_ckpt
):
checkpoint_info
=
CheckpointInfo
(
cmd_ckpt
)
checkpoint_info
=
CheckpointInfo
(
cmd_ckpt
)
...
...
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