Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save output node ID in file metadata #5235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions comfy_extras/nodes_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def insert_or_replace_vorbis_comment(flac_io, comment_dict):

class SaveAudio:
def __init__(self):
self.id: str
self.output_dir = folder_paths.get_output_directory()
self.type = "output"
self.prefix_append = ""
Expand Down Expand Up @@ -151,6 +152,7 @@ def save_audio(self, audio, filename_prefix="ComfyUI", prompt=None, extra_pnginf
if extra_pnginfo is not None:
for x in extra_pnginfo:
metadata[x] = json.dumps(extra_pnginfo[x])
metadata["output_node_id"] = self.id

for (batch_number, waveform) in enumerate(audio["waveform"].cpu()):
filename_with_batch_num = filename.replace("%batch_num%", str(batch_number))
Expand Down
1 change: 1 addition & 0 deletions execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ def execute(server, dynprompt, caches, current_item, extra_data, executed, promp
obj = caches.objects.get(unique_id)
if obj is None:
obj = class_def()
obj.id = unique_id
caches.objects.set(unique_id, obj)

if hasattr(obj, "check_lazy_status"):
Expand Down
2 changes: 2 additions & 0 deletions nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,7 @@ def sample(self, model, add_noise, noise_seed, steps, cfg, sampler_name, schedul

class SaveImage:
def __init__(self):
self.id: str
self.output_dir = folder_paths.get_output_directory()
self.type = "output"
self.prefix_append = ""
Expand Down Expand Up @@ -1512,6 +1513,7 @@ def save_images(self, images, filename_prefix="ComfyUI", prompt=None, extra_pngi
if extra_pnginfo is not None:
for x in extra_pnginfo:
metadata.add_text(x, json.dumps(extra_pnginfo[x]))
metadata.add_text("output_node_id", self.id)

filename_with_batch_num = filename.replace("%batch_num%", str(batch_number))
file = f"{filename_with_batch_num}_{counter:05}_.png"
Expand Down