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
f53ca516
Commit
f53ca516
authored
Oct 25, 2022
by
AUTOMATIC1111
Committed by
GitHub
Oct 25, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3549 from tsngo/on-image-saved-callback
add callback after image is saved
parents
77a320f4
16416e42
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
modules/images.py
modules/images.py
+2
-1
modules/script_callbacks.py
modules/script_callbacks.py
+12
-2
No files found.
modules/images.py
View file @
f53ca516
...
@@ -16,7 +16,7 @@ from PIL import Image, ImageFont, ImageDraw, PngImagePlugin
...
@@ -16,7 +16,7 @@ from PIL import Image, ImageFont, ImageDraw, PngImagePlugin
from
fonts.ttf
import
Roboto
from
fonts.ttf
import
Roboto
import
string
import
string
from
modules
import
sd_samplers
,
shared
from
modules
import
sd_samplers
,
shared
,
script_callbacks
from
modules.shared
import
opts
,
cmd_opts
from
modules.shared
import
opts
,
cmd_opts
LANCZOS
=
(
Image
.
Resampling
.
LANCZOS
if
hasattr
(
Image
,
'Resampling'
)
else
Image
.
LANCZOS
)
LANCZOS
=
(
Image
.
Resampling
.
LANCZOS
if
hasattr
(
Image
,
'Resampling'
)
else
Image
.
LANCZOS
)
...
@@ -539,6 +539,7 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
...
@@ -539,6 +539,7 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
else
:
else
:
txt_fullfn
=
None
txt_fullfn
=
None
script_callbacks
.
image_saved_callback
(
image
,
p
,
fullfn
,
txt_fullfn
)
return
fullfn
,
txt_fullfn
return
fullfn
,
txt_fullfn
...
...
modules/script_callbacks.py
View file @
f53ca516
...
@@ -13,11 +13,12 @@ ScriptCallback = namedtuple("ScriptCallback", ["script", "callback"])
...
@@ -13,11 +13,12 @@ ScriptCallback = namedtuple("ScriptCallback", ["script", "callback"])
callbacks_model_loaded
=
[]
callbacks_model_loaded
=
[]
callbacks_ui_tabs
=
[]
callbacks_ui_tabs
=
[]
callbacks_ui_settings
=
[]
callbacks_ui_settings
=
[]
callbacks_image_saved
=
[]
def
clear_callbacks
():
def
clear_callbacks
():
callbacks_model_loaded
.
clear
()
callbacks_model_loaded
.
clear
()
callbacks_ui_tabs
.
clear
()
callbacks_ui_tabs
.
clear
()
callbacks_image_saved
.
clear
()
def
model_loaded_callback
(
sd_model
):
def
model_loaded_callback
(
sd_model
):
...
@@ -55,6 +56,10 @@ def add_callback(callbacks, fun):
...
@@ -55,6 +56,10 @@ def add_callback(callbacks, fun):
callbacks
.
append
(
ScriptCallback
(
filename
,
fun
))
callbacks
.
append
(
ScriptCallback
(
filename
,
fun
))
def
image_saved_callback
(
image
,
p
,
fullfn
,
txt_fullfn
):
for
callback
in
callbacks_image_saved
:
callback
(
image
,
p
,
fullfn
,
txt_fullfn
)
def
on_model_loaded
(
callback
):
def
on_model_loaded
(
callback
):
"""register a function to be called when the stable diffusion model is created; the model is
"""register a function to be called when the stable diffusion model is created; the model is
passed as an argument"""
passed as an argument"""
...
@@ -77,4 +82,9 @@ def on_ui_tabs(callback):
...
@@ -77,4 +82,9 @@ def on_ui_tabs(callback):
def
on_ui_settings
(
callback
):
def
on_ui_settings
(
callback
):
"""register a function to be called before UI settings are populated; add your settings
"""register a function to be called before UI settings are populated; add your settings
by using shared.opts.add_option(shared.OptionInfo(...)) """
by using shared.opts.add_option(shared.OptionInfo(...)) """
add_callback
(
callbacks_ui_settings
,
callback
)
callbacks_ui_settings
.
append
(
callback
)
def
on_save_imaged
(
callback
):
"""register a function to call after modules.images.save_image is called returning same values, original image and p """
callbacks_image_saved
.
append
(
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