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
c48ab36c
Commit
c48ab36c
authored
Apr 29, 2023
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alternate restore progress button implementation
parent
bd970040
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
99 additions
and
7 deletions
+99
-7
javascript/hints.js
javascript/hints.js
+1
-0
javascript/progressbar.js
javascript/progressbar.js
+2
-2
javascript/ui.js
javascript/ui.js
+45
-1
modules/call_queue.py
modules/call_queue.py
+1
-0
modules/progress.py
modules/progress.py
+18
-0
modules/ui.py
modules/ui.py
+32
-4
No files found.
javascript/hints.js
View file @
c48ab36c
...
@@ -22,6 +22,7 @@ titles = {
...
@@ -22,6 +22,7 @@ titles = {
"
\
u{1f4cb}
"
:
"
Apply selected styles to current prompt
"
,
"
\
u{1f4cb}
"
:
"
Apply selected styles to current prompt
"
,
"
\
u{1f4d2}
"
:
"
Paste available values into the field
"
,
"
\
u{1f4d2}
"
:
"
Paste available values into the field
"
,
"
\
u{1f3b4}
"
:
"
Show/hide extra networks
"
,
"
\
u{1f3b4}
"
:
"
Show/hide extra networks
"
,
"
\
u{1f300}
"
:
"
Restore progress
"
,
"
Inpaint a part of image
"
:
"
Draw a mask over an image, and the script will regenerate the masked area with content according to prompt
"
,
"
Inpaint a part of image
"
:
"
Draw a mask over an image, and the script will regenerate the masked area with content according to prompt
"
,
"
SD upscale
"
:
"
Upscale image normally, split result into tiles, improve each tile using img2img, merge whole image back
"
,
"
SD upscale
"
:
"
Upscale image normally, split result into tiles, improve each tile using img2img, merge whole image back
"
,
...
...
javascript/progressbar.js
View file @
c48ab36c
...
@@ -66,7 +66,7 @@ function randomId(){
...
@@ -66,7 +66,7 @@ function randomId(){
// starts sending progress requests to "/internal/progress" uri, creating progressbar above progressbarContainer element and
// starts sending progress requests to "/internal/progress" uri, creating progressbar above progressbarContainer element and
// preview inside gallery element. Cleans up all created stuff when the task is over and calls atEnd.
// preview inside gallery element. Cleans up all created stuff when the task is over and calls atEnd.
// calls onProgress every time there is a progress update
// calls onProgress every time there is a progress update
function
requestProgress
(
id_task
,
progressbarContainer
,
gallery
,
atEnd
,
onProgress
){
function
requestProgress
(
id_task
,
progressbarContainer
,
gallery
,
atEnd
,
onProgress
,
inactivityTimeout
=
40
){
var
dateStart
=
new
Date
()
var
dateStart
=
new
Date
()
var
wasEverActive
=
false
var
wasEverActive
=
false
var
parentProgressbar
=
progressbarContainer
.
parentNode
var
parentProgressbar
=
progressbarContainer
.
parentNode
...
@@ -138,7 +138,7 @@ function requestProgress(id_task, progressbarContainer, gallery, atEnd, onProgre
...
@@ -138,7 +138,7 @@ function requestProgress(id_task, progressbarContainer, gallery, atEnd, onProgre
return
return
}
}
if
(
elapsedFromStart
>
40
&&
!
res
.
queued
&&
!
res
.
active
){
if
(
elapsedFromStart
>
inactivityTimeout
&&
!
res
.
queued
&&
!
res
.
active
){
removeProgressBar
()
removeProgressBar
()
return
return
}
}
...
...
javascript/ui.js
View file @
c48ab36c
...
@@ -159,14 +159,24 @@ function showSubmitButtons(tabname, show){
...
@@ -159,14 +159,24 @@ function showSubmitButtons(tabname, show){
gradioApp
().
getElementById
(
tabname
+
'
_skip
'
).
style
.
display
=
show
?
"
none
"
:
"
block
"
gradioApp
().
getElementById
(
tabname
+
'
_skip
'
).
style
.
display
=
show
?
"
none
"
:
"
block
"
}
}
function
showRestoreProgressButton
(
tabname
,
show
){
button
=
gradioApp
().
getElementById
(
tabname
+
"
_restore_progress
"
)
if
(
!
button
)
return
button
.
style
.
display
=
show
?
"
flex
"
:
"
none
"
}
function
submit
(){
function
submit
(){
rememberGallerySelection
(
'
txt2img_gallery
'
)
rememberGallerySelection
(
'
txt2img_gallery
'
)
showSubmitButtons
(
'
txt2img
'
,
false
)
showSubmitButtons
(
'
txt2img
'
,
false
)
var
id
=
randomId
()
var
id
=
randomId
()
localStorage
.
setItem
(
"
txt2img_task_id
"
,
id
);
requestProgress
(
id
,
gradioApp
().
getElementById
(
'
txt2img_gallery_container
'
),
gradioApp
().
getElementById
(
'
txt2img_gallery
'
),
function
(){
requestProgress
(
id
,
gradioApp
().
getElementById
(
'
txt2img_gallery_container
'
),
gradioApp
().
getElementById
(
'
txt2img_gallery
'
),
function
(){
showSubmitButtons
(
'
txt2img
'
,
true
)
showSubmitButtons
(
'
txt2img
'
,
true
)
localStorage
.
removeItem
(
"
txt2img_task_id
"
)
showRestoreProgressButton
(
'
txt2img
'
,
false
)
})
})
var
res
=
create_submit_args
(
arguments
)
var
res
=
create_submit_args
(
arguments
)
...
@@ -181,8 +191,12 @@ function submit_img2img(){
...
@@ -181,8 +191,12 @@ function submit_img2img(){
showSubmitButtons
(
'
img2img
'
,
false
)
showSubmitButtons
(
'
img2img
'
,
false
)
var
id
=
randomId
()
var
id
=
randomId
()
localStorage
.
setItem
(
"
img2img_task_id
"
,
id
);
requestProgress
(
id
,
gradioApp
().
getElementById
(
'
img2img_gallery_container
'
),
gradioApp
().
getElementById
(
'
img2img_gallery
'
),
function
(){
requestProgress
(
id
,
gradioApp
().
getElementById
(
'
img2img_gallery_container
'
),
gradioApp
().
getElementById
(
'
img2img_gallery
'
),
function
(){
showSubmitButtons
(
'
img2img
'
,
true
)
showSubmitButtons
(
'
img2img
'
,
true
)
localStorage
.
removeItem
(
"
img2img_task_id
"
)
showRestoreProgressButton
(
'
img2img
'
,
false
)
})
})
var
res
=
create_submit_args
(
arguments
)
var
res
=
create_submit_args
(
arguments
)
...
@@ -193,6 +207,36 @@ function submit_img2img(){
...
@@ -193,6 +207,36 @@ function submit_img2img(){
return
res
return
res
}
}
function
restoreProgressTxt2img
(
x
){
id
=
localStorage
.
getItem
(
"
txt2img_task_id
"
)
if
(
id
)
{
requestProgress
(
id
,
gradioApp
().
getElementById
(
'
txt2img_gallery_container
'
),
gradioApp
().
getElementById
(
'
txt2img_gallery
'
),
function
(){
showSubmitButtons
(
'
txt2img
'
,
true
)
},
null
,
0
)
}
return
[
id
]
}
function
restoreProgressImg2img
(
x
){
id
=
localStorage
.
getItem
(
"
img2img_task_id
"
)
if
(
id
)
{
requestProgress
(
id
,
gradioApp
().
getElementById
(
'
img2img_gallery_container
'
),
gradioApp
().
getElementById
(
'
img2img_gallery
'
),
function
(){
showSubmitButtons
(
'
img2img
'
,
true
)
},
null
,
0
)
}
return
[
id
]
}
onUiLoaded
(
function
()
{
showRestoreProgressButton
(
'
txt2img
'
,
localStorage
.
getItem
(
"
txt2img_task_id
"
))
showRestoreProgressButton
(
'
img2img
'
,
localStorage
.
getItem
(
"
img2img_task_id
"
))
});
function
modelmerger
(){
function
modelmerger
(){
var
id
=
randomId
()
var
id
=
randomId
()
requestProgress
(
id
,
gradioApp
().
getElementById
(
'
modelmerger_results_panel
'
),
null
,
function
(){})
requestProgress
(
id
,
gradioApp
().
getElementById
(
'
modelmerger_results_panel
'
),
null
,
function
(){})
...
...
modules/call_queue.py
View file @
c48ab36c
...
@@ -35,6 +35,7 @@ def wrap_gradio_gpu_call(func, extra_outputs=None):
...
@@ -35,6 +35,7 @@ def wrap_gradio_gpu_call(func, extra_outputs=None):
try
:
try
:
res
=
func
(
*
args
,
**
kwargs
)
res
=
func
(
*
args
,
**
kwargs
)
progress
.
record_results
(
id_task
,
res
)
finally
:
finally
:
progress
.
finish_task
(
id_task
)
progress
.
finish_task
(
id_task
)
...
...
modules/progress.py
View file @
c48ab36c
...
@@ -13,6 +13,8 @@ import modules.shared as shared
...
@@ -13,6 +13,8 @@ import modules.shared as shared
current_task
=
None
current_task
=
None
pending_tasks
=
{}
pending_tasks
=
{}
finished_tasks
=
[]
finished_tasks
=
[]
recorded_results
=
[]
recorded_results_limit
=
2
def
start_task
(
id_task
):
def
start_task
(
id_task
):
...
@@ -33,6 +35,12 @@ def finish_task(id_task):
...
@@ -33,6 +35,12 @@ def finish_task(id_task):
finished_tasks
.
pop
(
0
)
finished_tasks
.
pop
(
0
)
def
record_results
(
id_task
,
res
):
recorded_results
.
append
((
id_task
,
res
))
if
len
(
recorded_results
)
>
recorded_results_limit
:
recorded_results
.
pop
(
0
)
def
add_task_to_queue
(
id_job
):
def
add_task_to_queue
(
id_job
):
pending_tasks
[
id_job
]
=
time
.
time
()
pending_tasks
[
id_job
]
=
time
.
time
()
...
@@ -97,3 +105,13 @@ def progressapi(req: ProgressRequest):
...
@@ -97,3 +105,13 @@ def progressapi(req: ProgressRequest):
return
ProgressResponse
(
active
=
active
,
queued
=
queued
,
completed
=
completed
,
progress
=
progress
,
eta
=
eta
,
live_preview
=
live_preview
,
id_live_preview
=
id_live_preview
,
textinfo
=
shared
.
state
.
textinfo
)
return
ProgressResponse
(
active
=
active
,
queued
=
queued
,
completed
=
completed
,
progress
=
progress
,
eta
=
eta
,
live_preview
=
live_preview
,
id_live_preview
=
id_live_preview
,
textinfo
=
shared
.
state
.
textinfo
)
def
restore_progress
(
id_task
):
while
id_task
==
current_task
or
id_task
in
pending_tasks
:
time
.
sleep
(
0.1
)
res
=
next
(
iter
([
x
[
1
]
for
x
in
recorded_results
if
id_task
==
x
[
0
]]),
None
)
if
res
is
not
None
:
return
res
return
gr
.
update
(),
gr
.
update
(),
gr
.
update
(),
f
"Couldn't restore progress for {id_task}: results either have been discarded or never were obtained"
modules/ui.py
View file @
c48ab36c
...
@@ -19,7 +19,7 @@ import numpy as np
...
@@ -19,7 +19,7 @@ import numpy as np
from
PIL
import
Image
,
PngImagePlugin
from
PIL
import
Image
,
PngImagePlugin
from
modules.call_queue
import
wrap_gradio_gpu_call
,
wrap_queued_call
,
wrap_gradio_call
from
modules.call_queue
import
wrap_gradio_gpu_call
,
wrap_queued_call
,
wrap_gradio_call
from
modules
import
sd_hijack
,
sd_models
,
localization
,
script_callbacks
,
ui_extensions
,
deepbooru
,
sd_vae
,
extra_networks
,
postprocessing
,
ui_components
,
ui_common
,
ui_postprocessing
from
modules
import
sd_hijack
,
sd_models
,
localization
,
script_callbacks
,
ui_extensions
,
deepbooru
,
sd_vae
,
extra_networks
,
postprocessing
,
ui_components
,
ui_common
,
ui_postprocessing
,
progress
from
modules.ui_components
import
FormRow
,
FormColumn
,
FormGroup
,
ToolButton
,
FormHTML
from
modules.ui_components
import
FormRow
,
FormColumn
,
FormGroup
,
ToolButton
,
FormHTML
from
modules.paths
import
script_path
,
data_path
from
modules.paths
import
script_path
,
data_path
...
@@ -81,6 +81,7 @@ apply_style_symbol = '\U0001f4cb' # 📋
...
@@ -81,6 +81,7 @@ apply_style_symbol = '\U0001f4cb' # 📋
clear_prompt_symbol
=
'
\U0001f5d1\ufe0f
'
# 🗑️
clear_prompt_symbol
=
'
\U0001f5d1\ufe0f
'
# 🗑️
extra_networks_symbol
=
'
\U0001F3B4
'
# 🎴
extra_networks_symbol
=
'
\U0001F3B4
'
# 🎴
switch_values_symbol
=
'
\U000021C5
'
# ⇅
switch_values_symbol
=
'
\U000021C5
'
# ⇅
restore_progress_symbol
=
'
\U0001F300
'
# 🌀
def
plaintext_to_html
(
text
):
def
plaintext_to_html
(
text
):
...
@@ -325,6 +326,7 @@ def create_toprow(is_img2img):
...
@@ -325,6 +326,7 @@ def create_toprow(is_img2img):
extra_networks_button
=
ToolButton
(
value
=
extra_networks_symbol
,
elem_id
=
f
"{id_part}_extra_networks"
)
extra_networks_button
=
ToolButton
(
value
=
extra_networks_symbol
,
elem_id
=
f
"{id_part}_extra_networks"
)
prompt_style_apply
=
ToolButton
(
value
=
apply_style_symbol
,
elem_id
=
f
"{id_part}_style_apply"
)
prompt_style_apply
=
ToolButton
(
value
=
apply_style_symbol
,
elem_id
=
f
"{id_part}_style_apply"
)
save_style
=
ToolButton
(
value
=
save_style_symbol
,
elem_id
=
f
"{id_part}_style_create"
)
save_style
=
ToolButton
(
value
=
save_style_symbol
,
elem_id
=
f
"{id_part}_style_create"
)
restore_progress_button
=
ToolButton
(
value
=
restore_progress_symbol
,
elem_id
=
f
"{id_part}_restore_progress"
,
visible
=
False
)
token_counter
=
gr
.
HTML
(
value
=
"<span>0/75</span>"
,
elem_id
=
f
"{id_part}_token_counter"
,
elem_classes
=
[
"token-counter"
])
token_counter
=
gr
.
HTML
(
value
=
"<span>0/75</span>"
,
elem_id
=
f
"{id_part}_token_counter"
,
elem_classes
=
[
"token-counter"
])
token_button
=
gr
.
Button
(
visible
=
False
,
elem_id
=
f
"{id_part}_token_button"
)
token_button
=
gr
.
Button
(
visible
=
False
,
elem_id
=
f
"{id_part}_token_button"
)
...
@@ -342,7 +344,7 @@ def create_toprow(is_img2img):
...
@@ -342,7 +344,7 @@ def create_toprow(is_img2img):
prompt_styles
=
gr
.
Dropdown
(
label
=
"Styles"
,
elem_id
=
f
"{id_part}_styles"
,
choices
=
[
k
for
k
,
v
in
shared
.
prompt_styles
.
styles
.
items
()],
value
=
[],
multiselect
=
True
)
prompt_styles
=
gr
.
Dropdown
(
label
=
"Styles"
,
elem_id
=
f
"{id_part}_styles"
,
choices
=
[
k
for
k
,
v
in
shared
.
prompt_styles
.
styles
.
items
()],
value
=
[],
multiselect
=
True
)
create_refresh_button
(
prompt_styles
,
shared
.
prompt_styles
.
reload
,
lambda
:
{
"choices"
:
[
k
for
k
,
v
in
shared
.
prompt_styles
.
styles
.
items
()]},
f
"refresh_{id_part}_styles"
)
create_refresh_button
(
prompt_styles
,
shared
.
prompt_styles
.
reload
,
lambda
:
{
"choices"
:
[
k
for
k
,
v
in
shared
.
prompt_styles
.
styles
.
items
()]},
f
"refresh_{id_part}_styles"
)
return
prompt
,
prompt_styles
,
negative_prompt
,
submit
,
button_interrogate
,
button_deepbooru
,
prompt_style_apply
,
save_style
,
paste
,
extra_networks_button
,
token_counter
,
token_button
,
negative_token_counter
,
negative_token_button
return
prompt
,
prompt_styles
,
negative_prompt
,
submit
,
button_interrogate
,
button_deepbooru
,
prompt_style_apply
,
save_style
,
paste
,
extra_networks_button
,
token_counter
,
token_button
,
negative_token_counter
,
negative_token_button
,
restore_progress_button
def
setup_progressbar
(
*
args
,
**
kwargs
):
def
setup_progressbar
(
*
args
,
**
kwargs
):
...
@@ -459,7 +461,7 @@ def create_ui():
...
@@ -459,7 +461,7 @@ def create_ui():
modules
.
scripts
.
scripts_txt2img
.
initialize_scripts
(
is_img2img
=
False
)
modules
.
scripts
.
scripts_txt2img
.
initialize_scripts
(
is_img2img
=
False
)
with
gr
.
Blocks
(
analytics_enabled
=
False
)
as
txt2img_interface
:
with
gr
.
Blocks
(
analytics_enabled
=
False
)
as
txt2img_interface
:
txt2img_prompt
,
txt2img_prompt_styles
,
txt2img_negative_prompt
,
submit
,
_
,
_
,
txt2img_prompt_style_apply
,
txt2img_save_style
,
txt2img_paste
,
extra_networks_button
,
token_counter
,
token_button
,
negative_token_counter
,
negative_token_button
=
create_toprow
(
is_img2img
=
False
)
txt2img_prompt
,
txt2img_prompt_styles
,
txt2img_negative_prompt
,
submit
,
_
,
_
,
txt2img_prompt_style_apply
,
txt2img_save_style
,
txt2img_paste
,
extra_networks_button
,
token_counter
,
token_button
,
negative_token_counter
,
negative_token_button
,
restore_progress_button
=
create_toprow
(
is_img2img
=
False
)
dummy_component
=
gr
.
Label
(
visible
=
False
)
dummy_component
=
gr
.
Label
(
visible
=
False
)
txt_prompt_img
=
gr
.
File
(
label
=
""
,
elem_id
=
"txt2img_prompt_image"
,
file_count
=
"single"
,
type
=
"binary"
,
visible
=
False
)
txt_prompt_img
=
gr
.
File
(
label
=
""
,
elem_id
=
"txt2img_prompt_image"
,
file_count
=
"single"
,
type
=
"binary"
,
visible
=
False
)
...
@@ -591,6 +593,19 @@ def create_ui():
...
@@ -591,6 +593,19 @@ def create_ui():
res_switch_btn
.
click
(
lambda
w
,
h
:
(
h
,
w
),
inputs
=
[
width
,
height
],
outputs
=
[
width
,
height
],
show_progress
=
False
)
res_switch_btn
.
click
(
lambda
w
,
h
:
(
h
,
w
),
inputs
=
[
width
,
height
],
outputs
=
[
width
,
height
],
show_progress
=
False
)
restore_progress_button
.
click
(
fn
=
progress
.
restore_progress
,
_js
=
"restoreProgressTxt2img"
,
inputs
=
[
dummy_component
],
outputs
=
[
txt2img_gallery
,
generation_info
,
html_info
,
html_log
,
],
show_progress
=
False
,
)
txt_prompt_img
.
change
(
txt_prompt_img
.
change
(
fn
=
modules
.
images
.
image_data
,
fn
=
modules
.
images
.
image_data
,
inputs
=
[
inputs
=
[
...
@@ -659,7 +674,7 @@ def create_ui():
...
@@ -659,7 +674,7 @@ def create_ui():
modules
.
scripts
.
scripts_img2img
.
initialize_scripts
(
is_img2img
=
True
)
modules
.
scripts
.
scripts_img2img
.
initialize_scripts
(
is_img2img
=
True
)
with
gr
.
Blocks
(
analytics_enabled
=
False
)
as
img2img_interface
:
with
gr
.
Blocks
(
analytics_enabled
=
False
)
as
img2img_interface
:
img2img_prompt
,
img2img_prompt_styles
,
img2img_negative_prompt
,
submit
,
img2img_interrogate
,
img2img_deepbooru
,
img2img_prompt_style_apply
,
img2img_save_style
,
img2img_paste
,
extra_networks_button
,
token_counter
,
token_button
,
negative_token_counter
,
negative_token_button
=
create_toprow
(
is_img2img
=
True
)
img2img_prompt
,
img2img_prompt_styles
,
img2img_negative_prompt
,
submit
,
img2img_interrogate
,
img2img_deepbooru
,
img2img_prompt_style_apply
,
img2img_save_style
,
img2img_paste
,
extra_networks_button
,
token_counter
,
token_button
,
negative_token_counter
,
negative_token_button
,
restore_progress_button
=
create_toprow
(
is_img2img
=
True
)
img2img_prompt_img
=
gr
.
File
(
label
=
""
,
elem_id
=
"img2img_prompt_image"
,
file_count
=
"single"
,
type
=
"binary"
,
visible
=
False
)
img2img_prompt_img
=
gr
.
File
(
label
=
""
,
elem_id
=
"img2img_prompt_image"
,
file_count
=
"single"
,
type
=
"binary"
,
visible
=
False
)
...
@@ -951,6 +966,19 @@ def create_ui():
...
@@ -951,6 +966,19 @@ def create_ui():
submit
.
click
(
**
img2img_args
)
submit
.
click
(
**
img2img_args
)
res_switch_btn
.
click
(
lambda
w
,
h
:
(
h
,
w
),
inputs
=
[
width
,
height
],
outputs
=
[
width
,
height
],
show_progress
=
False
)
res_switch_btn
.
click
(
lambda
w
,
h
:
(
h
,
w
),
inputs
=
[
width
,
height
],
outputs
=
[
width
,
height
],
show_progress
=
False
)
restore_progress_button
.
click
(
fn
=
progress
.
restore_progress
,
_js
=
"restoreProgressImg2img"
,
inputs
=
[
dummy_component
],
outputs
=
[
img2img_gallery
,
generation_info
,
html_info
,
html_log
,
],
show_progress
=
False
,
)
img2img_interrogate
.
click
(
img2img_interrogate
.
click
(
fn
=
lambda
*
args
:
process_interrogate
(
interrogate
,
*
args
),
fn
=
lambda
*
args
:
process_interrogate
(
interrogate
,
*
args
),
**
interrogate_args
,
**
interrogate_args
,
...
...
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