improve: ControlBridge supports bypass control

This commit is contained in:
Dr.Lt.Data
2023-12-10 11:38:40 +09:00
parent f0d3bd9d29
commit 9dfd983da9
4 changed files with 41 additions and 13 deletions
+3 -1
View File
@@ -197,7 +197,9 @@ This takes latent as input and outputs latent as the result.
* Sleep - Waits for the specified time (in seconds).
* Set Widget Value - This node sets one of the optional inputs to the specified node's widget. An error may occur if the types do not match.
* Set Mute State - This node changes the mute state of a specific node.
* Control Bridge - Depending on whether the mode is set to `block` or `pass`, it changes the mute status of connected nodes. If there are nodes that require a change, the current execution is paused, the mute status is updated, and a new prompt queue is inserted.
* Control Bridge - This node modifies the state of the connected control nodes based on the `mode` and `behavior` . If there are nodes that require a change, the current execution is paused, the mute status is updated, and a new prompt queue is inserted.
* When the `mode` is `active`, it makes the connected control nodes active regardless of the behavior.
* When the `mode` is `Bypass/Mute`, it changes the state of the connected nodes based on whether the behavior is `Bypass` or `Mute`.
* **Limitation**: Due to these characteristics, it does not function correctly when the batch count exceeds 1. Additionally, it does not guarantee proper operation when the seed is randomized or when the state of nodes is altered by actions such as `Queue Trigger`, `Set Widget Value`, `Set Mute`, before the Control Bridge.
* When utilizing this node, please structure the workflow in such a way that `Queue Trigger`, `Set Widget Value`, `Set Mute State`, and similar actions are executed at the end of the workflow.
* If you want to change the value of the seed at each iteration, please ensure that Set Widget Value is executed at the end of the workflow instead of using randomization.
+4
View File
@@ -53,6 +53,7 @@ async function bridgeContinue(event) {
if(node) {
const mutes = new Set(event.detail.mutes);
const actives = new Set(event.detail.actives);
const bypasses = new Set(event.detail.bypasses);
for(let i in app.graph._nodes_by_id) {
let this_node = app.graph._nodes_by_id[i];
@@ -62,6 +63,9 @@ async function bridgeContinue(event) {
else if(actives.has(i)) {
this_node.mode = 0;
}
else if(bypasses.has(i)) {
this_node.mode = 4;
}
}
await app.queuePrompt(0, 1);
+1 -1
View File
@@ -2,7 +2,7 @@ import configparser
import os
version = "V4.42.1"
version = "V4.43"
dependency_version = 19
+33 -11
View File
@@ -447,7 +447,8 @@ class ImpactControlBridge:
def INPUT_TYPES(cls):
return {"required": {
"value": (any_typ,),
"mode": ("BOOLEAN", {"default": True, "label_on": "pass", "label_off": "block"}),
"mode": ("BOOLEAN", {"default": True, "label_on": "Active", "label_off": "Mute/Bypass"}),
"behavior": ("BOOLEAN", {"default": True, "label_on": "Mute", "label_off": "Bypass"}),
},
"hidden": {"unique_id": "UNIQUE_ID", "prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"}
}
@@ -459,26 +460,47 @@ class ImpactControlBridge:
RETURN_NAMES = ("value",)
OUTPUT_NODE = True
def doit(self, value, mode, unique_id, prompt, extra_pnginfo):
def doit(self, value, mode, behavior=True, unique_id=None, prompt=None, extra_pnginfo=None):
global error_skip_flag
nodes, links = workflow_to_map(extra_pnginfo['workflow'])
outputs = [str(links[link][2]) for link in nodes[unique_id]['outputs'][0]['links']]
active_nodes = []
mute_nodes = []
bypass_nodes = []
prompt_set = set(prompt.keys())
output_set = set(outputs)
for link in nodes[unique_id]['outputs'][0]['links']:
node_id = str(links[link][2])
node_mode = nodes[node_id]['mode']
if node_mode == 0:
active_nodes.append(node_id)
elif node_mode == 2:
mute_nodes.append(node_id)
elif node_mode == 4:
bypass_nodes.append(node_id)
if mode:
should_active_but_muted = output_set - prompt_set
if len(should_active_but_muted) > 0:
PromptServer.instance.send_sync("impact-bridge-continue", {"node_id": unique_id, 'actives': list(should_active_but_muted)})
# active
should_be_active_nodes = mute_nodes + bypass_nodes
if len(should_be_active_nodes) > 0:
PromptServer.instance.send_sync("impact-bridge-continue", {"node_id": unique_id, 'actives': list(should_be_active_nodes)})
error_skip_flag = True
raise Exception("IMPACT-PACK-SIGNAL: STOP CONTROL BRIDGE\nIf you see this message, your ComfyUI-Manager is outdated. Please update it.")
elif behavior:
# mute
should_be_mute_nodes = active_nodes + bypass_nodes
if len(should_be_mute_nodes) > 0:
PromptServer.instance.send_sync("impact-bridge-continue", {"node_id": unique_id, 'mutes': list(should_be_mute_nodes)})
error_skip_flag = True
raise Exception("IMPACT-PACK-SIGNAL: STOP CONTROL BRIDGE\nIf you see this message, your ComfyUI-Manager is outdated. Please update it.")
else:
should_muted_but_active = prompt_set.intersection(output_set)
if len(should_muted_but_active) > 0:
PromptServer.instance.send_sync("impact-bridge-continue", {"node_id": unique_id, 'mutes': list(should_muted_but_active)})
# bypass
should_be_bypass_nodes = active_nodes + mute_nodes
if len(should_be_bypass_nodes) > 0:
PromptServer.instance.send_sync("impact-bridge-continue", {"node_id": unique_id, 'bypasses': list(should_be_bypass_nodes)})
error_skip_flag = True
raise Exception("IMPACT-PACK-SIGNAL: STOP CONTROL BRIDGE\nIf you see this message, your ComfyUI-Manager is outdated. Please update it.")