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
abacb735
Commit
abacb735
authored
Jun 10, 2024
by
w-e-w
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multi size grid
parent
d2097dbd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
modules/images.py
modules/images.py
+6
-3
scripts/xyz_grid.py
scripts/xyz_grid.py
+5
-3
No files found.
modules/images.py
View file @
abacb735
...
@@ -54,11 +54,14 @@ def image_grid(imgs, batch_size=1, rows=None):
...
@@ -54,11 +54,14 @@ def image_grid(imgs, batch_size=1, rows=None):
params
=
script_callbacks
.
ImageGridLoopParams
(
imgs
,
cols
,
rows
)
params
=
script_callbacks
.
ImageGridLoopParams
(
imgs
,
cols
,
rows
)
script_callbacks
.
image_grid_callback
(
params
)
script_callbacks
.
image_grid_callback
(
params
)
w
,
h
=
imgs
[
0
]
.
size
w
,
h
=
map
(
max
,
zip
(
*
(
img
.
size
for
img
in
imgs
)))
grid
=
Image
.
new
(
'RGB'
,
size
=
(
params
.
cols
*
w
,
params
.
rows
*
h
),
color
=
'black'
)
grid_background_color
=
ImageColor
.
getcolor
(
opts
.
grid_background_color
,
'RGB'
)
grid
=
Image
.
new
(
'RGB'
,
size
=
(
params
.
cols
*
w
,
params
.
rows
*
h
),
color
=
grid_background_color
)
for
i
,
img
in
enumerate
(
params
.
imgs
):
for
i
,
img
in
enumerate
(
params
.
imgs
):
grid
.
paste
(
img
,
box
=
(
i
%
params
.
cols
*
w
,
i
//
params
.
cols
*
h
))
img_w
,
img_h
=
img
.
size
w_offset
,
h_offset
=
0
if
img_w
==
w
else
(
w
-
img_w
)
//
2
,
0
if
img_h
==
h
else
(
h
-
img_h
)
//
2
grid
.
paste
(
img
,
box
=
(
i
%
params
.
cols
*
w
+
w_offset
,
i
//
params
.
cols
*
h
+
h_offset
))
return
grid
return
grid
...
...
scripts/xyz_grid.py
View file @
abacb735
...
@@ -375,16 +375,18 @@ def draw_xyz_grid(p, xs, ys, zs, x_labels, y_labels, z_labels, cell, draw_legend
...
@@ -375,16 +375,18 @@ def draw_xyz_grid(p, xs, ys, zs, x_labels, y_labels, z_labels, cell, draw_legend
end_index
=
start_index
+
len
(
xs
)
*
len
(
ys
)
end_index
=
start_index
+
len
(
xs
)
*
len
(
ys
)
grid
=
images
.
image_grid
(
processed_result
.
images
[
start_index
:
end_index
],
rows
=
len
(
ys
))
grid
=
images
.
image_grid
(
processed_result
.
images
[
start_index
:
end_index
],
rows
=
len
(
ys
))
if
draw_legend
:
if
draw_legend
:
grid
=
images
.
draw_grid_annotations
(
grid
,
processed_result
.
images
[
start_index
]
.
size
[
0
],
processed_result
.
images
[
start_index
]
.
size
[
1
],
hor_texts
,
ver_texts
,
margin_size
)
grid_max_w
,
grid_max_h
=
map
(
max
,
zip
(
*
(
img
.
size
for
img
in
processed_result
.
images
[
start_index
:
end_index
])))
grid
=
images
.
draw_grid_annotations
(
grid
,
grid_max_w
,
grid_max_h
,
hor_texts
,
ver_texts
,
margin_size
)
processed_result
.
images
.
insert
(
i
,
grid
)
processed_result
.
images
.
insert
(
i
,
grid
)
processed_result
.
all_prompts
.
insert
(
i
,
processed_result
.
all_prompts
[
start_index
])
processed_result
.
all_prompts
.
insert
(
i
,
processed_result
.
all_prompts
[
start_index
])
processed_result
.
all_seeds
.
insert
(
i
,
processed_result
.
all_seeds
[
start_index
])
processed_result
.
all_seeds
.
insert
(
i
,
processed_result
.
all_seeds
[
start_index
])
processed_result
.
infotexts
.
insert
(
i
,
processed_result
.
infotexts
[
start_index
])
processed_result
.
infotexts
.
insert
(
i
,
processed_result
.
infotexts
[
start_index
])
sub_grid_size
=
processed_result
.
images
[
0
]
.
size
#
sub_grid_size = processed_result.images[0].size
z_grid
=
images
.
image_grid
(
processed_result
.
images
[:
z_count
],
rows
=
1
)
z_grid
=
images
.
image_grid
(
processed_result
.
images
[:
z_count
],
rows
=
1
)
z_sub_grid_max_w
,
z_sub_grid_max_h
=
map
(
max
,
zip
(
*
(
img
.
size
for
img
in
processed_result
.
images
[:
z_count
])))
if
draw_legend
:
if
draw_legend
:
z_grid
=
images
.
draw_grid_annotations
(
z_grid
,
sub_grid_size
[
0
],
sub_grid_size
[
1
]
,
title_texts
,
[[
images
.
GridAnnotation
()]])
z_grid
=
images
.
draw_grid_annotations
(
z_grid
,
z_sub_grid_max_w
,
z_sub_grid_max_h
,
title_texts
,
[[
images
.
GridAnnotation
()]])
processed_result
.
images
.
insert
(
0
,
z_grid
)
processed_result
.
images
.
insert
(
0
,
z_grid
)
# TODO: Deeper aspects of the program rely on grid info being misaligned between metadata arrays, which is not ideal.
# TODO: Deeper aspects of the program rely on grid info being misaligned between metadata arrays, which is not ideal.
# processed_result.all_prompts.insert(0, processed_result.all_prompts[0])
# processed_result.all_prompts.insert(0, processed_result.all_prompts[0])
...
...
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