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
6062c85d
Unverified
Commit
6062c85d
authored
Jan 01, 2023
by
AUTOMATIC1111
Committed by
GitHub
Jan 01, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6094 from AlUlkesh/master
Adding image numbers on grids
parents
524d532b
5f12b23b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
images.py
modules/images.py
+1
-0
script_callbacks.py
modules/script_callbacks.py
+20
-0
No files found.
modules/images.py
View file @
6062c85d
...
...
@@ -43,6 +43,7 @@ def image_grid(imgs, batch_size=1, rows=None):
grid
=
Image
.
new
(
'RGB'
,
size
=
(
cols
*
w
,
rows
*
h
),
color
=
'black'
)
for
i
,
img
in
enumerate
(
imgs
):
script_callbacks
.
image_grid_loop_callback
(
img
)
grid
.
paste
(
img
,
box
=
(
i
%
cols
*
w
,
i
//
cols
*
h
))
return
grid
...
...
modules/script_callbacks.py
View file @
6062c85d
...
...
@@ -51,6 +51,11 @@ class UiTrainTabParams:
self
.
txt2img_preview_params
=
txt2img_preview_params
class
ImageGridLoopParams
:
def
__init__
(
self
,
img
):
self
.
img
=
img
ScriptCallback
=
namedtuple
(
"ScriptCallback"
,
[
"script"
,
"callback"
])
callback_map
=
dict
(
callbacks_app_started
=
[],
...
...
@@ -63,6 +68,7 @@ callback_map = dict(
callbacks_cfg_denoiser
=
[],
callbacks_before_component
=
[],
callbacks_after_component
=
[],
callbacks_image_grid_loop
=
[],
)
...
...
@@ -154,6 +160,12 @@ def after_component_callback(component, **kwargs):
except
Exception
:
report_exception
(
c
,
'after_component_callback'
)
def
image_grid_loop_callback
(
component
,
**
kwargs
):
for
c
in
callback_map
[
'callbacks_image_grid_loop'
]:
try
:
c
.
callback
(
component
,
**
kwargs
)
except
Exception
:
report_exception
(
c
,
'image_grid_loop'
)
def
add_callback
(
callbacks
,
fun
):
stack
=
[
x
for
x
in
inspect
.
stack
()
if
x
.
filename
!=
__file__
]
...
...
@@ -255,3 +267,11 @@ def on_before_component(callback):
def
on_after_component
(
callback
):
"""register a function to be called after a component is created. See on_before_component for more."""
add_callback
(
callback_map
[
'callbacks_after_component'
],
callback
)
def
on_image_grid_loop
(
callback
):
"""register a function to be called inside the image grid loop.
The callback is called with one argument:
- params: ImageGridLoopParams - parameters to be used inside the image grid loop.
"""
add_callback
(
callback_map
[
'callbacks_image_grid_loop'
],
callback
)
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