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
71322400
Commit
71322400
authored
Apr 29, 2023
by
AUTOMATIC1111
Committed by
GitHub
Apr 29, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9392 from pangbo13/xyz-plot-dropdown
Add dropdown for X/Y/Z plot
parents
dda839f6
3ac5f9c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
24 deletions
+53
-24
scripts/xyz_grid.py
scripts/xyz_grid.py
+53
-24
No files found.
scripts/xyz_grid.py
View file @
71322400
...
@@ -374,16 +374,19 @@ class Script(scripts.Script):
...
@@ -374,16 +374,19 @@ class Script(scripts.Script):
with
gr
.
Row
():
with
gr
.
Row
():
x_type
=
gr
.
Dropdown
(
label
=
"X type"
,
choices
=
[
x
.
label
for
x
in
self
.
current_axis_options
],
value
=
self
.
current_axis_options
[
1
]
.
label
,
type
=
"index"
,
elem_id
=
self
.
elem_id
(
"x_type"
))
x_type
=
gr
.
Dropdown
(
label
=
"X type"
,
choices
=
[
x
.
label
for
x
in
self
.
current_axis_options
],
value
=
self
.
current_axis_options
[
1
]
.
label
,
type
=
"index"
,
elem_id
=
self
.
elem_id
(
"x_type"
))
x_values
=
gr
.
Textbox
(
label
=
"X values"
,
lines
=
1
,
elem_id
=
self
.
elem_id
(
"x_values"
))
x_values
=
gr
.
Textbox
(
label
=
"X values"
,
lines
=
1
,
elem_id
=
self
.
elem_id
(
"x_values"
))
x_values_dropdown
=
gr
.
Dropdown
(
label
=
"X values"
,
visible
=
False
,
multiselect
=
True
,
interactive
=
True
)
fill_x_button
=
ToolButton
(
value
=
fill_values_symbol
,
elem_id
=
"xyz_grid_fill_x_tool_button"
,
visible
=
False
)
fill_x_button
=
ToolButton
(
value
=
fill_values_symbol
,
elem_id
=
"xyz_grid_fill_x_tool_button"
,
visible
=
False
)
with
gr
.
Row
():
with
gr
.
Row
():
y_type
=
gr
.
Dropdown
(
label
=
"Y type"
,
choices
=
[
x
.
label
for
x
in
self
.
current_axis_options
],
value
=
self
.
current_axis_options
[
0
]
.
label
,
type
=
"index"
,
elem_id
=
self
.
elem_id
(
"y_type"
))
y_type
=
gr
.
Dropdown
(
label
=
"Y type"
,
choices
=
[
x
.
label
for
x
in
self
.
current_axis_options
],
value
=
self
.
current_axis_options
[
0
]
.
label
,
type
=
"index"
,
elem_id
=
self
.
elem_id
(
"y_type"
))
y_values
=
gr
.
Textbox
(
label
=
"Y values"
,
lines
=
1
,
elem_id
=
self
.
elem_id
(
"y_values"
))
y_values
=
gr
.
Textbox
(
label
=
"Y values"
,
lines
=
1
,
elem_id
=
self
.
elem_id
(
"y_values"
))
y_values_dropdown
=
gr
.
Dropdown
(
label
=
"Y values"
,
visible
=
False
,
multiselect
=
True
,
interactive
=
True
)
fill_y_button
=
ToolButton
(
value
=
fill_values_symbol
,
elem_id
=
"xyz_grid_fill_y_tool_button"
,
visible
=
False
)
fill_y_button
=
ToolButton
(
value
=
fill_values_symbol
,
elem_id
=
"xyz_grid_fill_y_tool_button"
,
visible
=
False
)
with
gr
.
Row
():
with
gr
.
Row
():
z_type
=
gr
.
Dropdown
(
label
=
"Z type"
,
choices
=
[
x
.
label
for
x
in
self
.
current_axis_options
],
value
=
self
.
current_axis_options
[
0
]
.
label
,
type
=
"index"
,
elem_id
=
self
.
elem_id
(
"z_type"
))
z_type
=
gr
.
Dropdown
(
label
=
"Z type"
,
choices
=
[
x
.
label
for
x
in
self
.
current_axis_options
],
value
=
self
.
current_axis_options
[
0
]
.
label
,
type
=
"index"
,
elem_id
=
self
.
elem_id
(
"z_type"
))
z_values
=
gr
.
Textbox
(
label
=
"Z values"
,
lines
=
1
,
elem_id
=
self
.
elem_id
(
"z_values"
))
z_values
=
gr
.
Textbox
(
label
=
"Z values"
,
lines
=
1
,
elem_id
=
self
.
elem_id
(
"z_values"
))
z_values_dropdown
=
gr
.
Dropdown
(
label
=
"Z values"
,
visible
=
False
,
multiselect
=
True
,
interactive
=
True
)
fill_z_button
=
ToolButton
(
value
=
fill_values_symbol
,
elem_id
=
"xyz_grid_fill_z_tool_button"
,
visible
=
False
)
fill_z_button
=
ToolButton
(
value
=
fill_values_symbol
,
elem_id
=
"xyz_grid_fill_z_tool_button"
,
visible
=
False
)
with
gr
.
Row
(
variant
=
"compact"
,
elem_id
=
"axis_options"
):
with
gr
.
Row
(
variant
=
"compact"
,
elem_id
=
"axis_options"
):
...
@@ -401,54 +404,74 @@ class Script(scripts.Script):
...
@@ -401,54 +404,74 @@ class Script(scripts.Script):
swap_yz_axes_button
=
gr
.
Button
(
value
=
"Swap Y/Z axes"
,
elem_id
=
"yz_grid_swap_axes_button"
)
swap_yz_axes_button
=
gr
.
Button
(
value
=
"Swap Y/Z axes"
,
elem_id
=
"yz_grid_swap_axes_button"
)
swap_xz_axes_button
=
gr
.
Button
(
value
=
"Swap X/Z axes"
,
elem_id
=
"xz_grid_swap_axes_button"
)
swap_xz_axes_button
=
gr
.
Button
(
value
=
"Swap X/Z axes"
,
elem_id
=
"xz_grid_swap_axes_button"
)
def
swap_axes
(
axis1_type
,
axis1_values
,
axis
2_type
,
axis2_values
):
def
swap_axes
(
axis1_type
,
axis1_values
,
axis
1_values_dropdown
,
axis2_type
,
axis2_values
,
axis2_values_dropdown
):
return
self
.
current_axis_options
[
axis2_type
]
.
label
,
axis2_values
,
self
.
current_axis_options
[
axis1_type
]
.
label
,
axis1_values
return
self
.
current_axis_options
[
axis2_type
]
.
label
,
axis2_values
,
axis2_values_dropdown
,
self
.
current_axis_options
[
axis1_type
]
.
label
,
axis1_values
,
axis1_values_dropdown
xy_swap_args
=
[
x_type
,
x_values
,
y_type
,
y_values
]
xy_swap_args
=
[
x_type
,
x_values
,
x_values_dropdown
,
y_type
,
y_values
,
y_values_dropdown
]
swap_xy_axes_button
.
click
(
swap_axes
,
inputs
=
xy_swap_args
,
outputs
=
xy_swap_args
)
swap_xy_axes_button
.
click
(
swap_axes
,
inputs
=
xy_swap_args
,
outputs
=
xy_swap_args
)
yz_swap_args
=
[
y_type
,
y_values
,
z_type
,
z_values
]
yz_swap_args
=
[
y_type
,
y_values
,
y_values_dropdown
,
z_type
,
z_values
,
z_values_dropdown
]
swap_yz_axes_button
.
click
(
swap_axes
,
inputs
=
yz_swap_args
,
outputs
=
yz_swap_args
)
swap_yz_axes_button
.
click
(
swap_axes
,
inputs
=
yz_swap_args
,
outputs
=
yz_swap_args
)
xz_swap_args
=
[
x_type
,
x_values
,
z_type
,
z_values
]
xz_swap_args
=
[
x_type
,
x_values
,
x_values_dropdown
,
z_type
,
z_values
,
z_values_dropdown
]
swap_xz_axes_button
.
click
(
swap_axes
,
inputs
=
xz_swap_args
,
outputs
=
xz_swap_args
)
swap_xz_axes_button
.
click
(
swap_axes
,
inputs
=
xz_swap_args
,
outputs
=
xz_swap_args
)
def
fill
(
x_type
):
def
fill
(
x_type
):
axis
=
self
.
current_axis_options
[
x_type
]
axis
=
self
.
current_axis_options
[
x_type
]
return
", "
.
join
(
axis
.
choices
())
if
axis
.
choices
else
gr
.
update
()
return
axis
.
choices
()
if
axis
.
choices
else
gr
.
update
()
fill_x_button
.
click
(
fn
=
fill
,
inputs
=
[
x_type
],
outputs
=
[
x_values
])
fill_x_button
.
click
(
fn
=
fill
,
inputs
=
[
x_type
],
outputs
=
[
x_values_dropdown
])
fill_y_button
.
click
(
fn
=
fill
,
inputs
=
[
y_type
],
outputs
=
[
y_values
])
fill_y_button
.
click
(
fn
=
fill
,
inputs
=
[
y_type
],
outputs
=
[
y_values_dropdown
])
fill_z_button
.
click
(
fn
=
fill
,
inputs
=
[
z_type
],
outputs
=
[
z_values
])
fill_z_button
.
click
(
fn
=
fill
,
inputs
=
[
z_type
],
outputs
=
[
z_values_dropdown
])
def
select_axis
(
x_type
):
def
select_axis
(
axis_type
,
axis_values_dropdown
):
return
gr
.
Button
.
update
(
visible
=
self
.
current_axis_options
[
x_type
]
.
choices
is
not
None
)
choices
=
self
.
current_axis_options
[
axis_type
]
.
choices
has_choices
=
choices
is
not
None
x_type
.
change
(
fn
=
select_axis
,
inputs
=
[
x_type
],
outputs
=
[
fill_x_button
])
current_values
=
axis_values_dropdown
y_type
.
change
(
fn
=
select_axis
,
inputs
=
[
y_type
],
outputs
=
[
fill_y_button
])
if
has_choices
:
z_type
.
change
(
fn
=
select_axis
,
inputs
=
[
z_type
],
outputs
=
[
fill_z_button
])
choices
=
choices
()
if
isinstance
(
current_values
,
str
):
current_values
=
current_values
.
split
(
","
)
current_values
=
list
(
filter
(
lambda
x
:
x
in
choices
,
current_values
))
return
gr
.
Button
.
update
(
visible
=
has_choices
),
gr
.
Textbox
.
update
(
visible
=
not
has_choices
),
gr
.
update
(
choices
=
choices
if
has_choices
else
None
,
visible
=
has_choices
,
value
=
current_values
)
x_type
.
change
(
fn
=
select_axis
,
inputs
=
[
x_type
,
x_values_dropdown
],
outputs
=
[
fill_x_button
,
x_values
,
x_values_dropdown
])
y_type
.
change
(
fn
=
select_axis
,
inputs
=
[
y_type
,
y_values_dropdown
],
outputs
=
[
fill_y_button
,
y_values
,
y_values_dropdown
])
z_type
.
change
(
fn
=
select_axis
,
inputs
=
[
z_type
,
z_values_dropdown
],
outputs
=
[
fill_z_button
,
z_values
,
z_values_dropdown
])
def
get_dropdown_update_from_params
(
axis
,
params
):
val_key
=
axis
+
" Values"
vals
=
params
.
get
(
val_key
,
""
)
valslist
=
[
x
.
strip
()
for
x
in
chain
.
from_iterable
(
csv
.
reader
(
StringIO
(
vals
)))
if
x
]
return
gr
.
update
(
value
=
valslist
)
self
.
infotext_fields
=
(
self
.
infotext_fields
=
(
(
x_type
,
"X Type"
),
(
x_type
,
"X Type"
),
(
x_values
,
"X Values"
),
(
x_values
,
"X Values"
),
(
x_values_dropdown
,
lambda
params
:
get_dropdown_update_from_params
(
"X"
,
params
)),
(
y_type
,
"Y Type"
),
(
y_type
,
"Y Type"
),
(
y_values
,
"Y Values"
),
(
y_values
,
"Y Values"
),
(
y_values_dropdown
,
lambda
params
:
get_dropdown_update_from_params
(
"Y"
,
params
)),
(
z_type
,
"Z Type"
),
(
z_type
,
"Z Type"
),
(
z_values
,
"Z Values"
),
(
z_values
,
"Z Values"
),
(
z_values_dropdown
,
lambda
params
:
get_dropdown_update_from_params
(
"Z"
,
params
)),
)
)
return
[
x_type
,
x_values
,
y_type
,
y_values
,
z_type
,
z_values
,
draw_legend
,
include_lone_images
,
include_sub_grids
,
no_fixed_seeds
,
margin_size
]
return
[
x_type
,
x_values
,
x_values_dropdown
,
y_type
,
y_values
,
y_values_dropdown
,
z_type
,
z_values
,
z_values_dropdown
,
draw_legend
,
include_lone_images
,
include_sub_grids
,
no_fixed_seeds
,
margin_size
]
def
run
(
self
,
p
,
x_type
,
x_values
,
y_type
,
y_values
,
z_type
,
z_values
,
draw_legend
,
include_lone_images
,
include_sub_grids
,
no_fixed_seeds
,
margin_size
):
def
run
(
self
,
p
,
x_type
,
x_values
,
x_values_dropdown
,
y_type
,
y_values
,
y_values_dropdown
,
z_type
,
z_values
,
z_values_dropdown
,
draw_legend
,
include_lone_images
,
include_sub_grids
,
no_fixed_seeds
,
margin_size
):
if
not
no_fixed_seeds
:
if
not
no_fixed_seeds
:
modules
.
processing
.
fix_seed
(
p
)
modules
.
processing
.
fix_seed
(
p
)
if
not
opts
.
return_grid
:
if
not
opts
.
return_grid
:
p
.
batch_size
=
1
p
.
batch_size
=
1
def
process_axis
(
opt
,
vals
):
def
process_axis
(
opt
,
vals
,
vals_dropdown
):
if
opt
.
label
==
'Nothing'
:
if
opt
.
label
==
'Nothing'
:
return
[
0
]
return
[
0
]
valslist
=
[
x
.
strip
()
for
x
in
chain
.
from_iterable
(
csv
.
reader
(
StringIO
(
vals
)))
if
x
]
if
opt
.
choices
is
not
None
:
valslist
=
vals_dropdown
else
:
valslist
=
[
x
.
strip
()
for
x
in
chain
.
from_iterable
(
csv
.
reader
(
StringIO
(
vals
)))
if
x
]
if
opt
.
type
==
int
:
if
opt
.
type
==
int
:
valslist_ext
=
[]
valslist_ext
=
[]
...
@@ -506,13 +529,19 @@ class Script(scripts.Script):
...
@@ -506,13 +529,19 @@ class Script(scripts.Script):
return
valslist
return
valslist
x_opt
=
self
.
current_axis_options
[
x_type
]
x_opt
=
self
.
current_axis_options
[
x_type
]
xs
=
process_axis
(
x_opt
,
x_values
)
if
x_opt
.
choices
is
not
None
:
x_values
=
","
.
join
(
x_values_dropdown
)
xs
=
process_axis
(
x_opt
,
x_values
,
x_values_dropdown
)
y_opt
=
self
.
current_axis_options
[
y_type
]
y_opt
=
self
.
current_axis_options
[
y_type
]
ys
=
process_axis
(
y_opt
,
y_values
)
if
y_opt
.
choices
is
not
None
:
y_values
=
","
.
join
(
y_values_dropdown
)
ys
=
process_axis
(
y_opt
,
y_values
,
y_values_dropdown
)
z_opt
=
self
.
current_axis_options
[
z_type
]
z_opt
=
self
.
current_axis_options
[
z_type
]
zs
=
process_axis
(
z_opt
,
z_values
)
if
z_opt
.
choices
is
not
None
:
z_values
=
","
.
join
(
z_values_dropdown
)
zs
=
process_axis
(
z_opt
,
z_values
,
z_values_dropdown
)
# this could be moved to common code, but unlikely to be ever triggered anywhere else
# this could be moved to common code, but unlikely to be ever triggered anywhere else
Image
.
MAX_IMAGE_PIXELS
=
None
# disable check in Pillow and rely on check below to allow large custom image sizes
Image
.
MAX_IMAGE_PIXELS
=
None
# disable check in Pillow and rely on check below to allow large custom image sizes
...
...
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