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
2028aa06
Unverified
Commit
2028aa06
authored
Dec 10, 2022
by
AUTOMATIC1111
Committed by
GitHub
Dec 10, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3198 from papuSpartan/master
Add Clear Prompt button to roll_col
parents
854bb0b5
6387043f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
4 deletions
+71
-4
hints.js
javascript/hints.js
+1
-0
ui.js
javascript/ui.js
+40
-0
shared.py
modules/shared.py
+1
-0
ui.py
modules/ui.py
+28
-3
style.css
style.css
+1
-1
No files found.
javascript/hints.js
View file @
2028aa06
...
...
@@ -17,6 +17,7 @@ titles = {
"
\
u2199
\
ufe0f"
:
"Read generation parameters from prompt or last generation if prompt is empty into user interface."
,
"
\
u{1f4c2}"
:
"Open images output directory"
,
"
\
u{1f4be}"
:
"Save style"
,
"
\
U0001F5D1"
:
"Clear prompt"
"
\
u{1f4cb}"
:
"Apply selected styles to current 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"
,
...
...
javascript/ui.js
View file @
2028aa06
...
...
@@ -131,6 +131,46 @@ function ask_for_style_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
clear_prompt
()
{
if
(
confirm
(
"Delete prompt?"
))
{
let
pos_prompt
=
gradioApp
().
querySelector
(
"#txt2img_prompt > label > textarea"
);
let
neg_prompt
=
gradioApp
().
querySelector
(
"#txt2img_neg_prompt > label > textarea"
);
if
(
selected_tab_id
()
==
"tab_txt2img"
)
{
}
else
{
pos_prompt
=
gradioApp
().
querySelector
(
"#img2img_prompt > label > textarea"
);
neg_prompt
=
gradioApp
().
querySelector
(
"#img2img_neg_prompt > label > textarea"
);
}
pos_prompt
.
value
=
""
neg_prompt
.
value
=
""
//update prompt values on server-side
pos_prompt
.
dispatchEvent
(
new
Event
(
"input"
,
{
bubbles
:
true
})
)
neg_prompt
.
dispatchEvent
(
new
Event
(
"input"
,
{
bubbles
:
true
})
)
return
true
}
else
return
false
}
opts
=
{}
...
...
modules/shared.py
View file @
2028aa06
...
...
@@ -401,6 +401,7 @@ options_templates.update(options_section(('ui', "User interface"), {
"js_modal_lightbox"
:
OptionInfo
(
True
,
"Enable full page image viewer"
),
"js_modal_lightbox_initially_zoomed"
:
OptionInfo
(
True
,
"Show images zoomed in by default in full page image viewer"
),
"show_progress_in_title"
:
OptionInfo
(
True
,
"Show generation progress in window title."
),
"clear_prompt_visible"
:
OptionInfo
(
True
,
"Show clear prompt button"
),
'quicksettings'
:
OptionInfo
(
"sd_model_checkpoint"
,
"Quicksettings list"
),
'localization'
:
OptionInfo
(
"None"
,
"Localization (requires restart)"
,
gr
.
Dropdown
,
lambda
:
{
"choices"
:
[
"None"
]
+
list
(
localization
.
localizations
.
keys
())},
refresh
=
lambda
:
localization
.
list_localizations
(
cmd_opts
.
localizations_dir
)),
}))
...
...
modules/ui.py
View file @
2028aa06
...
...
@@ -82,6 +82,7 @@ folder_symbol = '\U0001f4c2' # 📂
refresh_symbol
=
'
\U0001f504
'
# 🔄
save_style_symbol
=
'
\U0001f4be
'
# 💾
apply_style_symbol
=
'
\U0001f4cb
'
# 📋
clear_prompt_symbol
=
'
\U0001F5D1
'
# 🗑️
def
plaintext_to_html
(
text
):
...
...
@@ -316,6 +317,17 @@ def create_seed_inputs():
return
seed
,
reuse_seed
,
subseed
,
reuse_subseed
,
subseed_strength
,
seed_resize_from_h
,
seed_resize_from_w
,
seed_checkbox
def
connect_clear_prompt
(
button
):
"""Given clear button, prompt, and token_counter objects, setup clear prompt button click event"""
button
.
click
(
_js
=
"clear_prompt"
,
fn
=
None
,
inputs
=
[],
outputs
=
[],
)
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
(sub)seed value from generation info the to the seed field. If copying subseed and subseed strength
...
...
@@ -392,6 +404,12 @@ def create_toprow(is_img2img):
save_style
=
gr
.
Button
(
value
=
save_style_symbol
,
elem_id
=
"style_create"
)
prompt_style_apply
=
gr
.
Button
(
value
=
apply_style_symbol
,
elem_id
=
"style_apply"
)
clear_prompt_button
=
gr
.
Button
(
value
=
clear_prompt_symbol
,
elem_id
=
"clear_prompt"
,
visible
=
opts
.
clear_prompt_visible
)
token_counter
=
gr
.
HTML
(
value
=
"<span></span>"
,
elem_id
=
f
"{id_part}_token_counter"
)
token_button
=
gr
.
Button
(
visible
=
False
,
elem_id
=
f
"{id_part}_token_button"
)
...
...
@@ -429,7 +447,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
.
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
,
clear_prompt_button
def
setup_progressbar
(
progressbar
,
preview
,
id_part
,
textinfo
=
None
):
...
...
@@ -616,10 +634,14 @@ def create_ui():
modules
.
scripts
.
scripts_txt2img
.
initialize_scripts
(
is_img2img
=
False
)
with
gr
.
Blocks
(
analytics_enabled
=
False
)
as
txt2img_interface
:
txt2img_prompt
,
roll
,
txt2img_prompt_style
,
txt2img_negative_prompt
,
txt2img_prompt_style2
,
submit
,
_
,
_
,
txt2img_prompt_style_apply
,
txt2img_save_style
,
txt2img_paste
,
token_counter
,
token_button
=
create_toprow
(
is_img2img
=
False
)
txt2img_prompt
,
roll
,
txt2img_prompt_style
,
txt2img_negative_prompt
,
txt2img_prompt_style2
,
submit
,
_
,
_
,
txt2img_prompt_style_apply
,
txt2img_save_style
,
txt2img_paste
,
token_counter
,
token_button
,
clear_prompt_button
=
create_toprow
(
is_img2img
=
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
)
with
gr
.
Row
(
elem_id
=
'txt2img_progress_row'
):
with
gr
.
Column
(
scale
=
1
):
pass
...
...
@@ -664,6 +686,7 @@ def create_ui():
connect_reuse_seed
(
seed
,
reuse_seed
,
generation_info
,
dummy_component
,
is_subseed
=
False
)
connect_reuse_seed
(
subseed
,
reuse_subseed
,
generation_info
,
dummy_component
,
is_subseed
=
True
)
connect_clear_prompt
(
clear_prompt_button
)
txt2img_args
=
dict
(
fn
=
wrap_gradio_gpu_call
(
modules
.
txt2img
.
txt2img
),
...
...
@@ -770,7 +793,8 @@ def create_ui():
modules
.
scripts
.
scripts_img2img
.
initialize_scripts
(
is_img2img
=
True
)
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
,
clear_prompt_button
=
create_toprow
(
is_img2img
=
True
)
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
)
...
...
@@ -860,6 +884,7 @@ def create_ui():
connect_reuse_seed
(
seed
,
reuse_seed
,
generation_info
,
dummy_component
,
is_subseed
=
False
)
connect_reuse_seed
(
subseed
,
reuse_subseed
,
generation_info
,
dummy_component
,
is_subseed
=
True
)
connect_clear_prompt
(
clear_prompt_button
)
img2img_prompt_img
.
change
(
fn
=
modules
.
images
.
image_data
,
...
...
style.css
View file @
2028aa06
...
...
@@ -114,7 +114,7 @@
padding
:
0.4em
0
;
}
#roll
,
#paste
,
#style_create
,
#style_apply
{
#roll
_col
>
button
{
min-width
:
2em
;
min-height
:
2em
;
max-width
:
2em
;
...
...
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