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
9bb6b650
Commit
9bb6b650
authored
Oct 29, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add postprocess call for scripts
parent
35c45df2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
6 deletions
+30
-6
modules/processing.py
modules/processing.py
+9
-3
modules/scripts.py
modules/scripts.py
+21
-3
No files found.
modules/processing.py
View file @
9bb6b650
...
...
@@ -478,7 +478,7 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
model_hijack
.
embedding_db
.
load_textual_inversion_embeddings
()
if
p
.
scripts
is
not
None
:
p
.
scripts
.
run_alwayson_script
s
(
p
)
p
.
scripts
.
proces
s
(
p
)
infotexts
=
[]
output_images
=
[]
...
...
@@ -501,7 +501,7 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
seeds
=
p
.
all_seeds
[
n
*
p
.
batch_size
:(
n
+
1
)
*
p
.
batch_size
]
subseeds
=
p
.
all_subseeds
[
n
*
p
.
batch_size
:(
n
+
1
)
*
p
.
batch_size
]
if
(
len
(
prompts
)
==
0
)
:
if
len
(
prompts
)
==
0
:
break
with
devices
.
autocast
():
...
...
@@ -590,7 +590,13 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
images
.
save_image
(
grid
,
p
.
outpath_grids
,
"grid"
,
p
.
all_seeds
[
0
],
p
.
all_prompts
[
0
],
opts
.
grid_format
,
info
=
infotext
(),
short_filename
=
not
opts
.
grid_extended_filename
,
p
=
p
,
grid
=
True
)
devices
.
torch_gc
()
return
Processed
(
p
,
output_images
,
p
.
all_seeds
[
0
],
infotext
()
+
""
.
join
([
"
\n\n
"
+
x
for
x
in
comments
]),
subseed
=
p
.
all_subseeds
[
0
],
all_prompts
=
p
.
all_prompts
,
all_seeds
=
p
.
all_seeds
,
all_subseeds
=
p
.
all_subseeds
,
index_of_first_image
=
index_of_first_image
,
infotexts
=
infotexts
)
res
=
Processed
(
p
,
output_images
,
p
.
all_seeds
[
0
],
infotext
()
+
""
.
join
([
"
\n\n
"
+
x
for
x
in
comments
]),
subseed
=
p
.
all_subseeds
[
0
],
all_prompts
=
p
.
all_prompts
,
all_seeds
=
p
.
all_seeds
,
all_subseeds
=
p
.
all_subseeds
,
index_of_first_image
=
index_of_first_image
,
infotexts
=
infotexts
)
if
p
.
scripts
is
not
None
:
p
.
scripts
.
postprocess
(
p
,
res
)
return
res
class
StableDiffusionProcessingTxt2Img
(
StableDiffusionProcessing
):
...
...
modules/scripts.py
View file @
9bb6b650
...
...
@@ -64,7 +64,16 @@ class Script:
def
process
(
self
,
p
,
*
args
):
"""
This function is called before processing begins for AlwaysVisible scripts.
scripts. You can modify the processing object (p) here, inject hooks, etc.
You can modify the processing object (p) here, inject hooks, etc.
args contains all values returned by components from ui()
"""
pass
def
postprocess
(
self
,
p
,
processed
,
*
args
):
"""
This function is called after processing ends for AlwaysVisible scripts.
args contains all values returned by components from ui()
"""
pass
...
...
@@ -289,13 +298,22 @@ class ScriptRunner:
return
processed
def
run_alwayson_script
s
(
self
,
p
):
def
proces
s
(
self
,
p
):
for
script
in
self
.
alwayson_scripts
:
try
:
script_args
=
p
.
script_args
[
script
.
args_from
:
script
.
args_to
]
script
.
process
(
p
,
*
script_args
)
except
Exception
:
print
(
f
"Error running alwayson script: {script.filename}"
,
file
=
sys
.
stderr
)
print
(
f
"Error running process: {script.filename}"
,
file
=
sys
.
stderr
)
print
(
traceback
.
format_exc
(),
file
=
sys
.
stderr
)
def
postprocess
(
self
,
p
,
processed
):
for
script
in
self
.
alwayson_scripts
:
try
:
script_args
=
p
.
script_args
[
script
.
args_from
:
script
.
args_to
]
script
.
postprocess
(
p
,
processed
,
*
script_args
)
except
Exception
:
print
(
f
"Error running postprocess: {script.filename}"
,
file
=
sys
.
stderr
)
print
(
traceback
.
format_exc
(),
file
=
sys
.
stderr
)
def
reload_sources
(
self
,
cache
):
...
...
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