mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-11 23:00:51 +08:00
prevent erasing output of muted nodes
This commit is contained in:
parent
e8cb166027
commit
6e4b44a716
@ -314,10 +314,18 @@ def worklist_will_execute(prompt, outputs, worklist):
|
|||||||
return will_execute
|
return will_execute
|
||||||
|
|
||||||
|
|
||||||
def worklist_output_delete_if_changed(prompt, old_prompt, outputs, next_nodes):
|
def worklist_output_delete_if_changed(prompt, old_prompt, outputs, next_nodes, muted_nodes):
|
||||||
worklist = []
|
worklist = []
|
||||||
deleted = set()
|
deleted = set()
|
||||||
|
|
||||||
|
def has_muted_input(inputs):
|
||||||
|
for item in inputs.values():
|
||||||
|
if isinstance(item, list):
|
||||||
|
if item[0] in muted_nodes:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
# init seeds
|
# init seeds
|
||||||
for unique_id, value in prompt.items():
|
for unique_id, value in prompt.items():
|
||||||
inputs = value['inputs']
|
inputs = value['inputs']
|
||||||
@ -351,6 +359,8 @@ def worklist_output_delete_if_changed(prompt, old_prompt, outputs, next_nodes):
|
|||||||
if not to_delete:
|
if not to_delete:
|
||||||
if is_changed != is_changed_old:
|
if is_changed != is_changed_old:
|
||||||
to_delete = True
|
to_delete = True
|
||||||
|
elif unique_id in muted_nodes or has_muted_input(old_prompt[unique_id]['inputs']):
|
||||||
|
continue
|
||||||
elif unique_id not in old_prompt:
|
elif unique_id not in old_prompt:
|
||||||
to_delete = True
|
to_delete = True
|
||||||
elif inputs == old_prompt[unique_id]['inputs']:
|
elif inputs == old_prompt[unique_id]['inputs']:
|
||||||
@ -393,6 +403,7 @@ class PromptExecutor:
|
|||||||
self.outputs_ui = {}
|
self.outputs_ui = {}
|
||||||
self.old_prompt = {}
|
self.old_prompt = {}
|
||||||
self.server = server
|
self.server = server
|
||||||
|
self.prev_muted_nodes = set()
|
||||||
|
|
||||||
def handle_execution_error(self, prompt_id, prompt, current_outputs, executed, error, ex):
|
def handle_execution_error(self, prompt_id, prompt, current_outputs, executed, error, ex):
|
||||||
node_id = error["node_id"]
|
node_id = error["node_id"]
|
||||||
@ -442,6 +453,9 @@ class PromptExecutor:
|
|||||||
def execute(self, prompt, prompt_id, extra_data={}, execute_outputs=[]):
|
def execute(self, prompt, prompt_id, extra_data={}, execute_outputs=[]):
|
||||||
nodes.interrupt_processing(False)
|
nodes.interrupt_processing(False)
|
||||||
|
|
||||||
|
muted_nodes = set([str(node['id']) for node in extra_data['extra_pnginfo']['workflow']['nodes']]) - set(prompt.keys())
|
||||||
|
unmuted_nodes = self.prev_muted_nodes - muted_nodes
|
||||||
|
|
||||||
if "client_id" in extra_data:
|
if "client_id" in extra_data:
|
||||||
self.server.client_id = extra_data["client_id"]
|
self.server.client_id = extra_data["client_id"]
|
||||||
else:
|
else:
|
||||||
@ -455,14 +469,14 @@ class PromptExecutor:
|
|||||||
# delete cached outputs if nodes don't exist for them
|
# delete cached outputs if nodes don't exist for them
|
||||||
to_delete = []
|
to_delete = []
|
||||||
for o in self.outputs:
|
for o in self.outputs:
|
||||||
if o not in prompt:
|
if o in unmuted_nodes or (o not in prompt and o not in muted_nodes):
|
||||||
to_delete += [o]
|
to_delete += [o]
|
||||||
for o in to_delete:
|
for o in to_delete:
|
||||||
d = self.outputs.pop(o)
|
d = self.outputs.pop(o)
|
||||||
del d
|
del d
|
||||||
|
|
||||||
next_nodes = get_next_nodes_map(prompt)
|
next_nodes = get_next_nodes_map(prompt)
|
||||||
worklist_output_delete_if_changed(prompt, self.old_prompt, self.outputs, next_nodes)
|
worklist_output_delete_if_changed(prompt, self.old_prompt, self.outputs, next_nodes, muted_nodes)
|
||||||
|
|
||||||
current_outputs = set(self.outputs.keys())
|
current_outputs = set(self.outputs.keys())
|
||||||
for x in list(self.outputs_ui.keys()):
|
for x in list(self.outputs_ui.keys()):
|
||||||
@ -490,6 +504,8 @@ class PromptExecutor:
|
|||||||
if self.server.client_id is not None:
|
if self.server.client_id is not None:
|
||||||
self.server.send_sync("executing", {"node": None, "prompt_id": prompt_id}, self.server.client_id)
|
self.server.send_sync("executing", {"node": None, "prompt_id": prompt_id}, self.server.client_id)
|
||||||
|
|
||||||
|
self.prev_muted_nodes = muted_nodes
|
||||||
|
|
||||||
print("Prompt executed in {:.2f} seconds".format(time.perf_counter() - execution_start_time))
|
print("Prompt executed in {:.2f} seconds".format(time.perf_counter() - execution_start_time))
|
||||||
gc.collect()
|
gc.collect()
|
||||||
comfy.model_management.soft_empty_cache()
|
comfy.model_management.soft_empty_cache()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user