aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw-e-w <40751091+w-e-w@users.noreply.github.com>2023-06-19 15:37:20 +0900
committerw-e-w <40751091+w-e-w@users.noreply.github.com>2023-06-29 02:08:21 +0900
commit9c2a7f1e8bafcb59e566bf568fdefe1be95905fe (patch)
treed2cd7cf3cb4500e09360df63d9c3032d502e2a82
parent59419bd64a1581caccaac04dceb66c1c069a2db1 (diff)
add callback after_extra_networks_activate
-rw-r--r--modules/extra_networks.py3
-rw-r--r--modules/scripts.py23
2 files changed, 26 insertions, 0 deletions
diff --git a/modules/extra_networks.py b/modules/extra_networks.py
index 1f093df2..41799b0a 100644
--- a/modules/extra_networks.py
+++ b/modules/extra_networks.py
@@ -103,6 +103,9 @@ def activate(p, extra_network_data):
except Exception as e:
errors.display(e, f"activating extra network {extra_network_name}")
+ if p.scripts is not None:
+ p.scripts.after_extra_networks_activate(p, batch_number=p.iteration, prompts=p.prompts, seeds=p.seeds, subseeds=p.subseeds, extra_network_data=extra_network_data)
+
def deactivate(p, extra_network_data):
"""call deactivate for extra networks in extra_network_data in specified order, then call
diff --git a/modules/scripts.py b/modules/scripts.py
index 99bf836a..340f1480 100644
--- a/modules/scripts.py
+++ b/modules/scripts.py
@@ -116,6 +116,21 @@ class Script:
pass
+ def after_extra_networks_activate(self, p, *args, **kwargs):
+ """
+ Calledafter extra networks activation, before conds calculation
+ allow modification of the network after extra networks activation been applied
+ won't be call if p.disable_extra_networks
+
+ **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
+ - extra_network_data - list of ExtraNetworkParams for current stage
+ """
+ pass
+
def process_batch(self, p, *args, **kwargs):
"""
Same as process(), but called for every batch.
@@ -483,6 +498,14 @@ class ScriptRunner:
except Exception:
errors.report(f"Error running before_process_batch: {script.filename}", exc_info=True)
+ def after_extra_networks_activate(self, p, **kwargs):
+ for script in self.alwayson_scripts:
+ try:
+ script_args = p.script_args[script.args_from:script.args_to]
+ script.after_extra_networks_activate(p, *script_args, **kwargs)
+ except Exception:
+ errors.report(f"Error running after_extra_networks_activate: {script.filename}", exc_info=True)
+
def process_batch(self, p, **kwargs):
for script in self.alwayson_scripts:
try: