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
a2d635ad
Commit
a2d635ad
authored
Feb 22, 2023
by
space-nuko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add before_process_batch script callback
parent
0cc0ee1b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
modules/processing.py
modules/processing.py
+3
-0
modules/scripts.py
modules/scripts.py
+23
-0
No files found.
modules/processing.py
View file @
a2d635ad
...
...
@@ -597,6 +597,9 @@ 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
p
.
scripts
is
not
None
:
p
.
scripts
.
before_process_batch
(
p
,
batch_number
=
n
,
prompts
=
prompts
,
seeds
=
seeds
,
subseeds
=
subseeds
)
if
len
(
prompts
)
==
0
:
break
...
...
modules/scripts.py
View file @
a2d635ad
...
...
@@ -80,6 +80,20 @@ class Script:
pass
def
before_process_batch
(
self
,
p
,
*
args
,
**
kwargs
):
"""
Called before extra networks are parsed from the prompt, so you can add
new extra network keywords to the prompt with this callback.
**kwargs will have those items:
- batch_number - index of current batch, from 0 to number of batches-1
- prompts - list of prompts for current batch; you can change contents of this list but changing the number of entries will likely break things
- seeds - list of seeds for current batch
- subseeds - list of subseeds for current batch
"""
pass
def
process_batch
(
self
,
p
,
*
args
,
**
kwargs
):
"""
Same as process(), but called for every batch.
...
...
@@ -388,6 +402,15 @@ class ScriptRunner:
print
(
f
"Error running process: {script.filename}"
,
file
=
sys
.
stderr
)
print
(
traceback
.
format_exc
(),
file
=
sys
.
stderr
)
def
before_process_batch
(
self
,
p
,
**
kwargs
):
for
script
in
self
.
alwayson_scripts
:
try
:
script_args
=
p
.
script_args
[
script
.
args_from
:
script
.
args_to
]
script
.
before_process_batch
(
p
,
*
script_args
,
**
kwargs
)
except
Exception
:
print
(
f
"Error running before_process_batch: {script.filename}"
,
file
=
sys
.
stderr
)
print
(
traceback
.
format_exc
(),
file
=
sys
.
stderr
)
def
process_batch
(
self
,
p
,
**
kwargs
):
for
script
in
self
.
alwayson_scripts
:
try
:
...
...
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