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
08c6f009
Commit
08c6f009
authored
Jan 14, 2023
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
load hashes from cache for checkpoints that have them
add checkpoint hash to footer
parent
febd2b72
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
19 deletions
+48
-19
ui.js
javascript/ui.js
+16
-9
hashes.py
modules/hashes.py
+19
-7
sd_models.py
modules/sd_models.py
+6
-3
shared.py
modules/shared.py
+1
-0
ui.py
modules/ui.py
+2
-0
script.js
script.js
+4
-0
No files found.
javascript/ui.js
View file @
08c6f009
...
@@ -143,14 +143,6 @@ function confirm_clear_prompt(prompt, negative_prompt) {
...
@@ -143,14 +143,6 @@ function confirm_clear_prompt(prompt, negative_prompt) {
opts
=
{}
opts
=
{}
function
apply_settings
(
jsdata
){
console
.
log
(
jsdata
)
opts
=
JSON
.
parse
(
jsdata
)
return
jsdata
}
onUiUpdate
(
function
(){
onUiUpdate
(
function
(){
if
(
Object
.
keys
(
opts
).
length
!=
0
)
return
;
if
(
Object
.
keys
(
opts
).
length
!=
0
)
return
;
...
@@ -160,7 +152,7 @@ onUiUpdate(function(){
...
@@ -160,7 +152,7 @@ onUiUpdate(function(){
textarea
=
json_elem
.
querySelector
(
'textarea'
)
textarea
=
json_elem
.
querySelector
(
'textarea'
)
jsdata
=
textarea
.
value
jsdata
=
textarea
.
value
opts
=
JSON
.
parse
(
jsdata
)
opts
=
JSON
.
parse
(
jsdata
)
executeCallbacks
(
optionsChangedCallbacks
);
Object
.
defineProperty
(
textarea
,
'value'
,
{
Object
.
defineProperty
(
textarea
,
'value'
,
{
set
:
function
(
newValue
)
{
set
:
function
(
newValue
)
{
...
@@ -171,6 +163,8 @@ onUiUpdate(function(){
...
@@ -171,6 +163,8 @@ onUiUpdate(function(){
if
(
oldValue
!=
newValue
)
{
if
(
oldValue
!=
newValue
)
{
opts
=
JSON
.
parse
(
textarea
.
value
)
opts
=
JSON
.
parse
(
textarea
.
value
)
}
}
executeCallbacks
(
optionsChangedCallbacks
);
},
},
get
:
function
()
{
get
:
function
()
{
var
valueProp
=
Object
.
getOwnPropertyDescriptor
(
HTMLTextAreaElement
.
prototype
,
'value'
);
var
valueProp
=
Object
.
getOwnPropertyDescriptor
(
HTMLTextAreaElement
.
prototype
,
'value'
);
...
@@ -201,6 +195,19 @@ onUiUpdate(function(){
...
@@ -201,6 +195,19 @@ onUiUpdate(function(){
}
}
})
})
onOptionsChanged
(
function
(){
elem
=
gradioApp
().
getElementById
(
'sd_checkpoint_hash'
)
sd_checkpoint_hash
=
opts
.
sd_checkpoint_hash
||
""
shorthash
=
sd_checkpoint_hash
.
substr
(
0
,
10
)
if
(
elem
&&
elem
.
textContent
!=
shorthash
){
elem
.
textContent
=
shorthash
elem
.
title
=
sd_checkpoint_hash
elem
.
href
=
"https://google.com/search?q="
+
sd_checkpoint_hash
}
})
let
txt2img_textarea
,
img2img_textarea
=
undefined
;
let
txt2img_textarea
,
img2img_textarea
=
undefined
;
let
wait_time
=
800
let
wait_time
=
800
let
token_timeout
;
let
token_timeout
;
...
...
modules/hashes.py
View file @
08c6f009
...
@@ -42,23 +42,35 @@ def calculate_sha256(filename):
...
@@ -42,23 +42,35 @@ def calculate_sha256(filename):
return
hash_sha256
.
hexdigest
()
return
hash_sha256
.
hexdigest
()
def
sha256
(
filename
,
title
):
def
sha256
_from_cache
(
filename
,
title
):
hashes
=
cache
(
"hashes"
)
hashes
=
cache
(
"hashes"
)
ondisk_mtime
=
os
.
path
.
getmtime
(
filename
)
ondisk_mtime
=
os
.
path
.
getmtime
(
filename
)
if
title
in
hashes
:
if
title
not
in
hashes
:
cached_sha256
=
hashes
[
title
]
.
get
(
"sha256"
,
None
)
return
None
cached_mtime
=
hashes
[
title
]
.
get
(
"mtime"
,
0
)
cached_sha256
=
hashes
[
title
]
.
get
(
"sha256"
,
None
)
cached_mtime
=
hashes
[
title
]
.
get
(
"mtime"
,
0
)
if
ondisk_mtime
>
cached_mtime
or
cached_sha256
is
None
:
return
None
return
cached_sha256
def
sha256
(
filename
,
title
):
hashes
=
cache
(
"hashes"
)
if
ondisk_mtime
<=
cached_mtime
and
cached_sha256
is
not
None
:
sha256_value
=
sha256_from_cache
(
filename
,
title
)
return
cached_sha256
if
sha256_value
is
not
None
:
return
sha256_value
print
(
f
"Calculating sha256 for {filename}: "
,
end
=
''
)
print
(
f
"Calculating sha256 for {filename}: "
,
end
=
''
)
sha256_value
=
calculate_sha256
(
filename
)
sha256_value
=
calculate_sha256
(
filename
)
print
(
f
"{sha256_value}"
)
print
(
f
"{sha256_value}"
)
hashes
[
title
]
=
{
hashes
[
title
]
=
{
"mtime"
:
o
ndisk_mtime
,
"mtime"
:
o
s
.
path
.
getmtime
(
filename
)
,
"sha256"
:
sha256_value
,
"sha256"
:
sha256_value
,
}
}
...
...
modules/sd_models.py
View file @
08c6f009
...
@@ -44,9 +44,11 @@ class CheckpointInfo:
...
@@ -44,9 +44,11 @@ class CheckpointInfo:
self
.
title
=
name
self
.
title
=
name
self
.
model_name
=
os
.
path
.
splitext
(
name
.
replace
(
"/"
,
"_"
)
.
replace
(
"
\\
"
,
"_"
))[
0
]
self
.
model_name
=
os
.
path
.
splitext
(
name
.
replace
(
"/"
,
"_"
)
.
replace
(
"
\\
"
,
"_"
))[
0
]
self
.
hash
=
model_hash
(
filename
)
self
.
hash
=
model_hash
(
filename
)
self
.
ids
=
[
self
.
hash
,
self
.
model_name
,
self
.
title
,
f
'{name} [{self.hash}]'
]
self
.
shorthash
=
None
self
.
sha256
=
hashes
.
sha256_from_cache
(
self
.
filename
,
"checkpoint/"
+
self
.
title
)
self
.
sha256
=
None
self
.
shorthash
=
self
.
sha256
[
0
:
10
]
if
self
.
sha256
else
None
self
.
ids
=
[
self
.
hash
,
self
.
model_name
,
self
.
title
,
f
'{name} [{self.hash}]'
]
+
([
self
.
shorthash
,
self
.
sha256
]
if
self
.
shorthash
else
[])
def
register
(
self
):
def
register
(
self
):
checkpoints_list
[
self
.
title
]
=
self
checkpoints_list
[
self
.
title
]
=
self
...
@@ -269,6 +271,7 @@ def load_model_weights(model, checkpoint_info: CheckpointInfo, vae_file="auto"):
...
@@ -269,6 +271,7 @@ def load_model_weights(model, checkpoint_info: CheckpointInfo, vae_file="auto"):
model
.
sd_model_hash
=
sd_model_hash
model
.
sd_model_hash
=
sd_model_hash
model
.
sd_model_checkpoint
=
checkpoint_info
.
filename
model
.
sd_model_checkpoint
=
checkpoint_info
.
filename
model
.
sd_checkpoint_info
=
checkpoint_info
model
.
sd_checkpoint_info
=
checkpoint_info
shared
.
opts
.
data
[
"sd_checkpoint_hash"
]
=
checkpoint_info
.
sha256
model
.
logvar
=
model
.
logvar
.
to
(
devices
.
device
)
# fix for training
model
.
logvar
=
model
.
logvar
.
to
(
devices
.
device
)
# fix for training
...
...
modules/shared.py
View file @
08c6f009
...
@@ -458,6 +458,7 @@ options_templates.update(options_section(('sampler-params', "Sampler parameters"
...
@@ -458,6 +458,7 @@ options_templates.update(options_section(('sampler-params', "Sampler parameters"
options_templates
.
update
(
options_section
((
None
,
"Hidden options"
),
{
options_templates
.
update
(
options_section
((
None
,
"Hidden options"
),
{
"disabled_extensions"
:
OptionInfo
([],
"Disable those extensions"
),
"disabled_extensions"
:
OptionInfo
([],
"Disable those extensions"
),
"sd_checkpoint_hash"
:
OptionInfo
(
""
,
"SHA256 hash of the current checkpoint"
),
}))
}))
options_templates
.
update
()
options_templates
.
update
()
...
...
modules/ui.py
View file @
08c6f009
...
@@ -1841,4 +1841,6 @@ xformers: {xformers_version}
...
@@ -1841,4 +1841,6 @@ xformers: {xformers_version}
gradio: {gr.__version__}
gradio: {gr.__version__}
•
•
commit: <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/{commit}">{short_commit}</a>
commit: <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/{commit}">{short_commit}</a>
•
checkpoint: <a id="sd_checkpoint_hash">N/A</a>
"""
"""
script.js
View file @
08c6f009
...
@@ -14,6 +14,7 @@ function get_uiCurrentTabContent() {
...
@@ -14,6 +14,7 @@ function get_uiCurrentTabContent() {
uiUpdateCallbacks
=
[]
uiUpdateCallbacks
=
[]
uiTabChangeCallbacks
=
[]
uiTabChangeCallbacks
=
[]
optionsChangedCallbacks
=
[]
let
uiCurrentTab
=
null
let
uiCurrentTab
=
null
function
onUiUpdate
(
callback
){
function
onUiUpdate
(
callback
){
...
@@ -22,6 +23,9 @@ function onUiUpdate(callback){
...
@@ -22,6 +23,9 @@ function onUiUpdate(callback){
function
onUiTabChange
(
callback
){
function
onUiTabChange
(
callback
){
uiTabChangeCallbacks
.
push
(
callback
)
uiTabChangeCallbacks
.
push
(
callback
)
}
}
function
onOptionsChanged
(
callback
){
optionsChangedCallbacks
.
push
(
callback
)
}
function
runCallback
(
x
,
m
){
function
runCallback
(
x
,
m
){
try
{
try
{
...
...
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