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
a1cf55a9
Commit
a1cf55a9
authored
Jan 03, 2023
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add option to reorder items in main UI
parent
9d4eff09
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
46 deletions
+97
-46
shared.py
modules/shared.py
+13
-0
ui.py
modules/ui.py
+84
-46
No files found.
modules/shared.py
View file @
a1cf55a9
...
@@ -109,6 +109,17 @@ restricted_opts = {
...
@@ -109,6 +109,17 @@ restricted_opts = {
"outdir_save"
,
"outdir_save"
,
}
}
ui_reorder_categories
=
[
"sampler"
,
"dimensions"
,
"cfg"
,
"seed"
,
"checkboxes"
,
"hires_fix"
,
"batch"
,
"scripts"
,
]
cmd_opts
.
disable_extension_access
=
(
cmd_opts
.
share
or
cmd_opts
.
listen
or
cmd_opts
.
server_name
)
and
not
cmd_opts
.
enable_insecure_extension_access
cmd_opts
.
disable_extension_access
=
(
cmd_opts
.
share
or
cmd_opts
.
listen
or
cmd_opts
.
server_name
)
and
not
cmd_opts
.
enable_insecure_extension_access
devices
.
device
,
devices
.
device_interrogate
,
devices
.
device_gfpgan
,
devices
.
device_esrgan
,
devices
.
device_codeformer
=
\
devices
.
device
,
devices
.
device_interrogate
,
devices
.
device_gfpgan
,
devices
.
device_esrgan
,
devices
.
device_codeformer
=
\
...
@@ -410,7 +421,9 @@ options_templates.update(options_section(('ui', "User interface"), {
...
@@ -410,7 +421,9 @@ options_templates.update(options_section(('ui', "User interface"), {
"js_modal_lightbox_initially_zoomed"
:
OptionInfo
(
True
,
"Show images zoomed in by default in 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."
),
"show_progress_in_title"
:
OptionInfo
(
True
,
"Show generation progress in window title."
),
"samplers_in_dropdown"
:
OptionInfo
(
True
,
"Use dropdown for sampler selection instead of radio group"
),
"samplers_in_dropdown"
:
OptionInfo
(
True
,
"Use dropdown for sampler selection instead of radio group"
),
"dimensions_and_batch_together"
:
OptionInfo
(
True
,
"Show Witdth/Height and Batch sliders in same row"
),
'quicksettings'
:
OptionInfo
(
"sd_model_checkpoint"
,
"Quicksettings list"
),
'quicksettings'
:
OptionInfo
(
"sd_model_checkpoint"
,
"Quicksettings list"
),
'ui_reorder'
:
OptionInfo
(
", "
.
join
(
ui_reorder_categories
),
"txt2img/ing2img UI item order"
),
'localization'
:
OptionInfo
(
"None"
,
"Localization (requires restart)"
,
gr
.
Dropdown
,
lambda
:
{
"choices"
:
[
"None"
]
+
list
(
localization
.
localizations
.
keys
())},
refresh
=
lambda
:
localization
.
list_localizations
(
cmd_opts
.
localizations_dir
)),
'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 @
a1cf55a9
...
@@ -644,6 +644,13 @@ def create_sampler_and_steps_selection(choices, tabname):
...
@@ -644,6 +644,13 @@ def create_sampler_and_steps_selection(choices, tabname):
return
steps
,
sampler_index
return
steps
,
sampler_index
def
ordered_ui_categories
():
user_order
=
{
x
.
strip
():
i
for
i
,
x
in
enumerate
(
shared
.
opts
.
ui_reorder
.
split
(
","
))}
for
i
,
category
in
sorted
(
enumerate
(
shared
.
ui_reorder_categories
),
key
=
lambda
x
:
user_order
.
get
(
x
[
1
],
x
[
0
]
+
1000
)):
yield
category
def
create_ui
():
def
create_ui
():
import
modules.img2img
import
modules.img2img
import
modules.txt2img
import
modules.txt2img
...
@@ -672,30 +679,46 @@ def create_ui():
...
@@ -672,30 +679,46 @@ def create_ui():
with
gr
.
Row
()
.
style
(
equal_height
=
False
):
with
gr
.
Row
()
.
style
(
equal_height
=
False
):
with
gr
.
Column
(
variant
=
'panel'
,
elem_id
=
"txt2img_settings"
):
with
gr
.
Column
(
variant
=
'panel'
,
elem_id
=
"txt2img_settings"
):
for
category
in
ordered_ui_categories
():
if
category
==
"sampler"
:
steps
,
sampler_index
=
create_sampler_and_steps_selection
(
samplers
,
"txt2img"
)
steps
,
sampler_index
=
create_sampler_and_steps_selection
(
samplers
,
"txt2img"
)
elif
category
==
"dimensions"
:
with
FormRow
():
with
FormRow
():
with
gr
.
Column
(
elem_id
=
"txt2img_column_size"
,
scale
=
4
):
with
gr
.
Column
(
elem_id
=
"txt2img_column_size"
,
scale
=
4
):
width
=
gr
.
Slider
(
minimum
=
64
,
maximum
=
2048
,
step
=
8
,
label
=
"Width"
,
value
=
512
,
elem_id
=
"txt2img_width"
)
width
=
gr
.
Slider
(
minimum
=
64
,
maximum
=
2048
,
step
=
8
,
label
=
"Width"
,
value
=
512
,
elem_id
=
"txt2img_width"
)
height
=
gr
.
Slider
(
minimum
=
64
,
maximum
=
2048
,
step
=
8
,
label
=
"Height"
,
value
=
512
,
elem_id
=
"txt2img_height"
)
height
=
gr
.
Slider
(
minimum
=
64
,
maximum
=
2048
,
step
=
8
,
label
=
"Height"
,
value
=
512
,
elem_id
=
"txt2img_height"
)
if
opts
.
dimensions_and_batch_together
:
with
gr
.
Column
(
elem_id
=
"txt2img_column_batch"
):
with
gr
.
Column
(
elem_id
=
"txt2img_column_batch"
):
batch_count
=
gr
.
Slider
(
minimum
=
1
,
step
=
1
,
label
=
'Batch count'
,
value
=
1
,
elem_id
=
"txt2img_batch_count"
)
batch_count
=
gr
.
Slider
(
minimum
=
1
,
step
=
1
,
label
=
'Batch count'
,
value
=
1
,
elem_id
=
"txt2img_batch_count"
)
batch_size
=
gr
.
Slider
(
minimum
=
1
,
maximum
=
8
,
step
=
1
,
label
=
'Batch size'
,
value
=
1
,
elem_id
=
"txt2img_batch_size"
)
batch_size
=
gr
.
Slider
(
minimum
=
1
,
maximum
=
8
,
step
=
1
,
label
=
'Batch size'
,
value
=
1
,
elem_id
=
"txt2img_batch_size"
)
elif
category
==
"cfg"
:
cfg_scale
=
gr
.
Slider
(
minimum
=
1.0
,
maximum
=
30.0
,
step
=
0.5
,
label
=
'CFG Scale'
,
value
=
7.0
,
elem_id
=
"txt2img_cfg_scale"
)
cfg_scale
=
gr
.
Slider
(
minimum
=
1.0
,
maximum
=
30.0
,
step
=
0.5
,
label
=
'CFG Scale'
,
value
=
7.0
,
elem_id
=
"txt2img_cfg_scale"
)
elif
category
==
"seed"
:
seed
,
reuse_seed
,
subseed
,
reuse_subseed
,
subseed_strength
,
seed_resize_from_h
,
seed_resize_from_w
,
seed_checkbox
=
create_seed_inputs
(
'txt2img'
)
seed
,
reuse_seed
,
subseed
,
reuse_subseed
,
subseed_strength
,
seed_resize_from_h
,
seed_resize_from_w
,
seed_checkbox
=
create_seed_inputs
(
'txt2img'
)
elif
category
==
"checkboxes"
:
with
FormRow
(
elem_id
=
"txt2img_checkboxes"
):
with
FormRow
(
elem_id
=
"txt2img_checkboxes"
):
restore_faces
=
gr
.
Checkbox
(
label
=
'Restore faces'
,
value
=
False
,
visible
=
len
(
shared
.
face_restorers
)
>
1
,
elem_id
=
"txt2img_restore_faces"
)
restore_faces
=
gr
.
Checkbox
(
label
=
'Restore faces'
,
value
=
False
,
visible
=
len
(
shared
.
face_restorers
)
>
1
,
elem_id
=
"txt2img_restore_faces"
)
tiling
=
gr
.
Checkbox
(
label
=
'Tiling'
,
value
=
False
,
elem_id
=
"txt2img_tiling"
)
tiling
=
gr
.
Checkbox
(
label
=
'Tiling'
,
value
=
False
,
elem_id
=
"txt2img_tiling"
)
enable_hr
=
gr
.
Checkbox
(
label
=
'Hires. fix'
,
value
=
False
,
elem_id
=
"txt2img_enable_hr"
)
enable_hr
=
gr
.
Checkbox
(
label
=
'Hires. fix'
,
value
=
False
,
elem_id
=
"txt2img_enable_hr"
)
with
FormRow
(
visible
=
False
)
as
hr_options
:
elif
category
==
"hires_fix"
:
with
FormRow
(
visible
=
False
,
elem_id
=
"txt2img_hires_fix"
)
as
hr_options
:
hr_upscaler
=
gr
.
Dropdown
(
label
=
"Upscaler"
,
elem_id
=
"txt2img_hr_upscaler"
,
choices
=
[
*
shared
.
latent_upscale_modes
,
*
[
x
.
name
for
x
in
shared
.
sd_upscalers
]],
value
=
shared
.
latent_upscale_default_mode
)
hr_upscaler
=
gr
.
Dropdown
(
label
=
"Upscaler"
,
elem_id
=
"txt2img_hr_upscaler"
,
choices
=
[
*
shared
.
latent_upscale_modes
,
*
[
x
.
name
for
x
in
shared
.
sd_upscalers
]],
value
=
shared
.
latent_upscale_default_mode
)
hr_scale
=
gr
.
Slider
(
minimum
=
1.0
,
maximum
=
4.0
,
step
=
0.05
,
label
=
"Upscale by"
,
value
=
2.0
,
elem_id
=
"txt2img_hr_scale"
)
hr_scale
=
gr
.
Slider
(
minimum
=
1.0
,
maximum
=
4.0
,
step
=
0.05
,
label
=
"Upscale by"
,
value
=
2.0
,
elem_id
=
"txt2img_hr_scale"
)
denoising_strength
=
gr
.
Slider
(
minimum
=
0.0
,
maximum
=
1.0
,
step
=
0.01
,
label
=
'Denoising strength'
,
value
=
0.7
,
elem_id
=
"txt2img_denoising_strength"
)
denoising_strength
=
gr
.
Slider
(
minimum
=
0.0
,
maximum
=
1.0
,
step
=
0.01
,
label
=
'Denoising strength'
,
value
=
0.7
,
elem_id
=
"txt2img_denoising_strength"
)
elif
category
==
"batch"
:
if
not
opts
.
dimensions_and_batch_together
:
with
FormRow
(
elem_id
=
"txt2img_column_batch"
):
batch_count
=
gr
.
Slider
(
minimum
=
1
,
step
=
1
,
label
=
'Batch count'
,
value
=
1
,
elem_id
=
"txt2img_batch_count"
)
batch_size
=
gr
.
Slider
(
minimum
=
1
,
maximum
=
8
,
step
=
1
,
label
=
'Batch size'
,
value
=
1
,
elem_id
=
"txt2img_batch_size"
)
elif
category
==
"scripts"
:
with
FormGroup
(
elem_id
=
"txt2img_script_container"
):
with
FormGroup
(
elem_id
=
"txt2img_script_container"
):
custom_inputs
=
modules
.
scripts
.
scripts_txt2img
.
setup_ui
()
custom_inputs
=
modules
.
scripts
.
scripts_txt2img
.
setup_ui
()
...
@@ -865,26 +888,41 @@ def create_ui():
...
@@ -865,26 +888,41 @@ def create_ui():
with
FormRow
():
with
FormRow
():
resize_mode
=
gr
.
Radio
(
label
=
"Resize mode"
,
elem_id
=
"resize_mode"
,
choices
=
[
"Just resize"
,
"Crop and resize"
,
"Resize and fill"
,
"Just resize (latent upscale)"
],
type
=
"index"
,
value
=
"Just resize"
)
resize_mode
=
gr
.
Radio
(
label
=
"Resize mode"
,
elem_id
=
"resize_mode"
,
choices
=
[
"Just resize"
,
"Crop and resize"
,
"Resize and fill"
,
"Just resize (latent upscale)"
],
type
=
"index"
,
value
=
"Just resize"
)
for
category
in
ordered_ui_categories
():
if
category
==
"sampler"
:
steps
,
sampler_index
=
create_sampler_and_steps_selection
(
samplers_for_img2img
,
"img2img"
)
steps
,
sampler_index
=
create_sampler_and_steps_selection
(
samplers_for_img2img
,
"img2img"
)
elif
category
==
"dimensions"
:
with
FormRow
():
with
FormRow
():
with
gr
.
Column
(
elem_id
=
"img2img_column_size"
,
scale
=
4
):
with
gr
.
Column
(
elem_id
=
"img2img_column_size"
,
scale
=
4
):
width
=
gr
.
Slider
(
minimum
=
64
,
maximum
=
2048
,
step
=
8
,
label
=
"Width"
,
value
=
512
,
elem_id
=
"img2img_width"
)
width
=
gr
.
Slider
(
minimum
=
64
,
maximum
=
2048
,
step
=
8
,
label
=
"Width"
,
value
=
512
,
elem_id
=
"img2img_width"
)
height
=
gr
.
Slider
(
minimum
=
64
,
maximum
=
2048
,
step
=
8
,
label
=
"Height"
,
value
=
512
,
elem_id
=
"img2img_height"
)
height
=
gr
.
Slider
(
minimum
=
64
,
maximum
=
2048
,
step
=
8
,
label
=
"Height"
,
value
=
512
,
elem_id
=
"img2img_height"
)
if
opts
.
dimensions_and_batch_together
:
with
gr
.
Column
(
elem_id
=
"img2img_column_batch"
):
with
gr
.
Column
(
elem_id
=
"img2img_column_batch"
):
batch_count
=
gr
.
Slider
(
minimum
=
1
,
step
=
1
,
label
=
'Batch count'
,
value
=
1
,
elem_id
=
"img2img_batch_count"
)
batch_count
=
gr
.
Slider
(
minimum
=
1
,
step
=
1
,
label
=
'Batch count'
,
value
=
1
,
elem_id
=
"img2img_batch_count"
)
batch_size
=
gr
.
Slider
(
minimum
=
1
,
maximum
=
8
,
step
=
1
,
label
=
'Batch size'
,
value
=
1
,
elem_id
=
"img2img_batch_size"
)
batch_size
=
gr
.
Slider
(
minimum
=
1
,
maximum
=
8
,
step
=
1
,
label
=
'Batch size'
,
value
=
1
,
elem_id
=
"img2img_batch_size"
)
elif
category
==
"cfg"
:
with
FormGroup
():
with
FormGroup
():
cfg_scale
=
gr
.
Slider
(
minimum
=
1.0
,
maximum
=
30.0
,
step
=
0.5
,
label
=
'CFG Scale'
,
value
=
7.0
,
elem_id
=
"img2img_cfg_scale"
)
cfg_scale
=
gr
.
Slider
(
minimum
=
1.0
,
maximum
=
30.0
,
step
=
0.5
,
label
=
'CFG Scale'
,
value
=
7.0
,
elem_id
=
"img2img_cfg_scale"
)
denoising_strength
=
gr
.
Slider
(
minimum
=
0.0
,
maximum
=
1.0
,
step
=
0.01
,
label
=
'Denoising strength'
,
value
=
0.75
,
elem_id
=
"img2img_denoising_strength"
)
denoising_strength
=
gr
.
Slider
(
minimum
=
0.0
,
maximum
=
1.0
,
step
=
0.01
,
label
=
'Denoising strength'
,
value
=
0.75
,
elem_id
=
"img2img_denoising_strength"
)
elif
category
==
"seed"
:
seed
,
reuse_seed
,
subseed
,
reuse_subseed
,
subseed_strength
,
seed_resize_from_h
,
seed_resize_from_w
,
seed_checkbox
=
create_seed_inputs
(
'img2img'
)
seed
,
reuse_seed
,
subseed
,
reuse_subseed
,
subseed_strength
,
seed_resize_from_h
,
seed_resize_from_w
,
seed_checkbox
=
create_seed_inputs
(
'img2img'
)
elif
category
==
"checkboxes"
:
with
FormRow
(
elem_id
=
"img2img_checkboxes"
):
with
FormRow
(
elem_id
=
"img2img_checkboxes"
):
restore_faces
=
gr
.
Checkbox
(
label
=
'Restore faces'
,
value
=
False
,
visible
=
len
(
shared
.
face_restorers
)
>
1
,
elem_id
=
"img2img_restore_faces"
)
restore_faces
=
gr
.
Checkbox
(
label
=
'Restore faces'
,
value
=
False
,
visible
=
len
(
shared
.
face_restorers
)
>
1
,
elem_id
=
"img2img_restore_faces"
)
tiling
=
gr
.
Checkbox
(
label
=
'Tiling'
,
value
=
False
,
elem_id
=
"img2img_tiling"
)
tiling
=
gr
.
Checkbox
(
label
=
'Tiling'
,
value
=
False
,
elem_id
=
"img2img_tiling"
)
elif
category
==
"batch"
:
if
not
opts
.
dimensions_and_batch_together
:
with
FormRow
(
elem_id
=
"img2img_column_batch"
):
batch_count
=
gr
.
Slider
(
minimum
=
1
,
step
=
1
,
label
=
'Batch count'
,
value
=
1
,
elem_id
=
"img2img_batch_count"
)
batch_size
=
gr
.
Slider
(
minimum
=
1
,
maximum
=
8
,
step
=
1
,
label
=
'Batch size'
,
value
=
1
,
elem_id
=
"img2img_batch_size"
)
elif
category
==
"scripts"
:
with
FormGroup
(
elem_id
=
"img2img_script_container"
):
with
FormGroup
(
elem_id
=
"img2img_script_container"
):
custom_inputs
=
modules
.
scripts
.
scripts_img2img
.
setup_ui
()
custom_inputs
=
modules
.
scripts
.
scripts_img2img
.
setup_ui
()
...
...
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