Skip to content

Commit a9e9799

Browse files
committed
process_one
1 parent 172c4bc commit a9e9799

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

modules/processing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,9 @@ def infotext(iteration=0, position_in_batch=0):
509509
if len(prompts) == 0:
510510
break
511511

512+
if p.scripts is not None:
513+
p.scripts.process_one(p)
514+
512515
with devices.autocast():
513516
uc = prompt_parser.get_learned_conditioning(shared.sd_model, len(prompts) * [p.negative_prompt], p.steps)
514517
c = prompt_parser.get_multicond_learned_conditioning(shared.sd_model, prompts, p.steps)

modules/scripts.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ def process(self, p, *args):
7070

7171
pass
7272

73+
def process_one(self, p, *args):
74+
"""
75+
Same as process(), but called for every iteration
76+
"""
77+
78+
pass
79+
7380
def postprocess(self, p, processed, *args):
7481
"""
7582
This function is called after processing ends for AlwaysVisible scripts.
@@ -294,6 +301,15 @@ def process(self, p):
294301
print(f"Error running process: {script.filename}", file=sys.stderr)
295302
print(traceback.format_exc(), file=sys.stderr)
296303

304+
def process_one(self, p):
305+
for script in self.alwayson_scripts:
306+
try:
307+
script_args = p.script_args[script.args_from:script.args_to]
308+
script.process_one(p, *script_args)
309+
except Exception:
310+
print(f"Error running process_one: {script.filename}", file=sys.stderr)
311+
print(traceback.format_exc(), file=sys.stderr)
312+
297313
def postprocess(self, p, processed):
298314
for script in self.alwayson_scripts:
299315
try:

0 commit comments

Comments
 (0)