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
158d678f
Commit
158d678f
authored
Oct 20, 2022
by
papuSpartan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clear prompt button now works on both relevant tabs. Device detection stuff will be added later.
parent
c6345bd4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
3 deletions
+46
-3
ui.js
javascript/ui.js
+28
-0
ui.py
modules/ui.py
+18
-3
No files found.
javascript/ui.js
View file @
158d678f
...
@@ -151,6 +151,34 @@ function ask_for_style_name(_, prompt_text, negative_prompt_text) {
...
@@ -151,6 +151,34 @@ function ask_for_style_name(_, prompt_text, negative_prompt_text) {
return
[
name_
,
prompt_text
,
negative_prompt_text
]
return
[
name_
,
prompt_text
,
negative_prompt_text
]
}
}
// returns css id for currently selected tab in ui
function
selected_tab_id
()
{
tabs
=
gradioApp
().
querySelectorAll
(
'#tabs div.tabitem'
)
for
(
var
tab
=
0
;
tab
<
tabs
.
length
;
tab
++
)
{
if
(
tabs
[
tab
].
style
.
display
!=
"none"
)
return
tabs
[
tab
].
id
}
}
function
trash_prompt
(
_
,
_
,
is_img2img
)
{
if
(
selected_tab_id
()
==
"tab_txt2img"
)
{
pos_prompt
=
txt2img_textarea
=
gradioApp
().
querySelector
(
"#txt2img_prompt > label > textarea"
);
neg_prompt
=
txt2img_textarea
=
gradioApp
().
querySelector
(
"#txt2img_neg_prompt > label > textarea"
);
pos_prompt
.
value
=
""
neg_prompt
.
value
=
""
}
else
{
pos_prompt
=
txt2img_textarea
=
gradioApp
().
querySelector
(
"#img2img_prompt > label > textarea"
);
neg_prompt
=
txt2img_textarea
=
gradioApp
().
querySelector
(
"#img2img_neg_prompt > label > textarea"
);
pos_prompt
.
value
=
""
neg_prompt
.
value
=
""
}
}
opts
=
{}
opts
=
{}
...
...
modules/ui.py
View file @
158d678f
...
@@ -424,6 +424,16 @@ def create_seed_inputs():
...
@@ -424,6 +424,16 @@ def create_seed_inputs():
return
seed
,
reuse_seed
,
subseed
,
reuse_subseed
,
subseed_strength
,
seed_resize_from_h
,
seed_resize_from_w
,
seed_checkbox
return
seed
,
reuse_seed
,
subseed
,
reuse_subseed
,
subseed_strength
,
seed_resize_from_h
,
seed_resize_from_w
,
seed_checkbox
# setup button for clearing prompt input boxes on client side of webui
def
connect_trash_prompt
(
dummy_component
,
button
,
is_img2img
):
button
.
click
(
fn
=
lambda
:
print
(
"Clearing prompt"
),
_js
=
"trash_prompt"
,
inputs
=
[],
outputs
=
[],
)
def
connect_reuse_seed
(
seed
:
gr
.
Number
,
reuse_seed
:
gr
.
Button
,
generation_info
:
gr
.
Textbox
,
dummy_component
,
is_subseed
):
def
connect_reuse_seed
(
seed
:
gr
.
Number
,
reuse_seed
:
gr
.
Button
,
generation_info
:
gr
.
Textbox
,
dummy_component
,
is_subseed
):
""" Connects a 'reuse (sub)seed' button's click event so that it copies last used
""" Connects a 'reuse (sub)seed' button's click event so that it copies last used
(sub)seed value from generation info the to the seed field. If copying subseed and subseed strength
(sub)seed value from generation info the to the seed field. If copying subseed and subseed strength
...
@@ -540,7 +550,7 @@ def create_toprow(is_img2img):
...
@@ -540,7 +550,7 @@ def create_toprow(is_img2img):
prompt_style2
=
gr
.
Dropdown
(
label
=
"Style 2"
,
elem_id
=
f
"{id_part}_style2_index"
,
choices
=
[
k
for
k
,
v
in
shared
.
prompt_styles
.
styles
.
items
()],
value
=
next
(
iter
(
shared
.
prompt_styles
.
styles
.
keys
())))
prompt_style2
=
gr
.
Dropdown
(
label
=
"Style 2"
,
elem_id
=
f
"{id_part}_style2_index"
,
choices
=
[
k
for
k
,
v
in
shared
.
prompt_styles
.
styles
.
items
()],
value
=
next
(
iter
(
shared
.
prompt_styles
.
styles
.
keys
())))
prompt_style2
.
save_to_config
=
True
prompt_style2
.
save_to_config
=
True
return
prompt
,
roll
,
prompt_style
,
negative_prompt
,
prompt_style2
,
submit
,
button_interrogate
,
button_deepbooru
,
prompt_style_apply
,
save_style
,
paste
,
token_counter
,
token_button
return
prompt
,
roll
,
prompt_style
,
negative_prompt
,
prompt_style2
,
submit
,
button_interrogate
,
button_deepbooru
,
prompt_style_apply
,
save_style
,
paste
,
token_counter
,
token_button
,
trash_prompt
def
setup_progressbar
(
progressbar
,
preview
,
id_part
,
textinfo
=
None
):
def
setup_progressbar
(
progressbar
,
preview
,
id_part
,
textinfo
=
None
):
...
@@ -619,10 +629,11 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -619,10 +629,11 @@ def create_ui(wrap_gradio_gpu_call):
with
gr
.
Blocks
(
analytics_enabled
=
False
)
as
txt2img_interface
:
with
gr
.
Blocks
(
analytics_enabled
=
False
)
as
txt2img_interface
:
txt2img_prompt
,
roll
,
txt2img_prompt_style
,
txt2img_negative_prompt
,
txt2img_prompt_style2
,
submit
,
_
,
_
,
\
txt2img_prompt
,
roll
,
txt2img_prompt_style
,
txt2img_negative_prompt
,
txt2img_prompt_style2
,
submit
,
_
,
_
,
\
txt2img_prompt_style_apply
,
txt2img_save_style
,
txt2img_paste
,
token_counter
,
\
txt2img_prompt_style_apply
,
txt2img_save_style
,
txt2img_paste
,
token_counter
,
\
token_button
=
create_toprow
(
is_img2img
=
False
)
token_button
,
trash_prompt_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
=
"bytes"
,
visible
=
False
)
txt_prompt_img
=
gr
.
File
(
label
=
""
,
elem_id
=
"txt2img_prompt_image"
,
file_count
=
"single"
,
type
=
"bytes"
,
visible
=
False
)
connect_trash_prompt
(
dummy_component
,
trash_prompt_button
,
False
)
with
gr
.
Row
(
elem_id
=
'txt2img_progress_row'
):
with
gr
.
Row
(
elem_id
=
'txt2img_progress_row'
):
with
gr
.
Column
(
scale
=
1
):
with
gr
.
Column
(
scale
=
1
):
...
@@ -807,7 +818,11 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -807,7 +818,11 @@ def create_ui(wrap_gradio_gpu_call):
token_button
.
click
(
fn
=
update_token_counter
,
inputs
=
[
txt2img_prompt
,
steps
],
outputs
=
[
token_counter
])
token_button
.
click
(
fn
=
update_token_counter
,
inputs
=
[
txt2img_prompt
,
steps
],
outputs
=
[
token_counter
])
with
gr
.
Blocks
(
analytics_enabled
=
False
)
as
img2img_interface
:
with
gr
.
Blocks
(
analytics_enabled
=
False
)
as
img2img_interface
:
img2img_prompt
,
roll
,
img2img_prompt_style
,
img2img_negative_prompt
,
img2img_prompt_style2
,
submit
,
img2img_interrogate
,
img2img_deepbooru
,
img2img_prompt_style_apply
,
img2img_save_style
,
img2img_paste
,
token_counter
,
token_button
=
create_toprow
(
is_img2img
=
True
)
img2img_prompt
,
roll
,
img2img_prompt_style
,
img2img_negative_prompt
,
img2img_prompt_style2
,
submit
,
\
img2img_interrogate
,
img2img_deepbooru
,
img2img_prompt_style_apply
,
img2img_save_style
,
img2img_paste
,
\
token_counter
,
token_button
,
trash_prompt_button
=
create_toprow
(
is_img2img
=
True
)
connect_trash_prompt
(
dummy_component
,
trash_prompt_button
,
True
)
with
gr
.
Row
(
elem_id
=
'img2img_progress_row'
):
with
gr
.
Row
(
elem_id
=
'img2img_progress_row'
):
img2img_prompt_img
=
gr
.
File
(
label
=
""
,
elem_id
=
"img2img_prompt_image"
,
file_count
=
"single"
,
type
=
"bytes"
,
visible
=
False
)
img2img_prompt_img
=
gr
.
File
(
label
=
""
,
elem_id
=
"img2img_prompt_image"
,
file_count
=
"single"
,
type
=
"bytes"
,
visible
=
False
)
...
...
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