Skip to content

Commit eeb0733

Browse files
committed
change process_one virtual function for script to process_batch, add extra args and docs
1 parent 99043f3 commit eeb0733

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

modules/processing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def infotext(iteration=0, position_in_batch=0):
502502
break
503503

504504
if p.scripts is not None:
505-
p.scripts.process_one(p, n)
505+
p.scripts.process_batch(p, batch_number=n, prompts=prompts, seeds=seeds, subseeds=subseeds)
506506

507507
with devices.autocast():
508508
uc = prompt_parser.get_learned_conditioning(shared.sd_model, len(prompts) * [p.negative_prompt], p.steps)

modules/scripts.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,15 @@ def process(self, p, *args):
7373

7474
pass
7575

76-
def process_one(self, p, n, *args):
76+
def process_batch(self, p, *args, **kwargs):
7777
"""
78-
Same as process(), but called for every iteration
78+
Same as process(), but called for every batch.
79+
80+
**kwargs will have those items:
81+
- batch_number - index of current batch, from 0 to number of batches-1
82+
- prompts - list of prompts for current batch; you can change contents of this list but changing the number of entries will likely break things
83+
- seeds - list of seeds for current batch
84+
- subseeds - list of subseeds for current batch
7985
"""
8086

8187
pass
@@ -303,13 +309,13 @@ def process(self, p):
303309
print(f"Error running process: {script.filename}", file=sys.stderr)
304310
print(traceback.format_exc(), file=sys.stderr)
305311

306-
def process_one(self, p, n):
312+
def process_batch(self, p, **kwargs):
307313
for script in self.alwayson_scripts:
308314
try:
309315
script_args = p.script_args[script.args_from:script.args_to]
310-
script.process_one(p, n, *script_args)
316+
script.process_batch(p, *script_args, **kwargs)
311317
except Exception:
312-
print(f"Error running process_one: {script.filename}", file=sys.stderr)
318+
print(f"Error running process_batch: {script.filename}", file=sys.stderr)
313319
print(traceback.format_exc(), file=sys.stderr)
314320

315321
def postprocess(self, p, processed):

0 commit comments

Comments
 (0)