Fix output display when executed

This commit is contained in:
space-nuko 2023-05-15 18:34:10 -05:00
parent a72722d471
commit f9ef1b6155
2 changed files with 28 additions and 30 deletions

View File

@ -192,20 +192,20 @@ def get_output_data(obj, input_data_all_batches, server, unique_id, prompt_id):
if len(uis) > 0: if len(uis) > 0:
output_ui = {k: [y for x in uis for y in x[k]] for k in uis[0].keys()} output_ui = {k: [y for x in uis for y in x[k]] for k in uis[0].keys()}
all_outputs.append(output)
all_outputs_ui.append(output_ui)
# update the UI after each batch finishes # update the UI after each batch finishes
if server.client_id is not None: if server.client_id is not None:
message = { message = {
"node": unique_id, "node": unique_id,
"output": output_ui, "output": all_outputs_ui, # list of outputs so far
"prompt_id": prompt_id, "prompt_id": prompt_id,
"batch_num": batch_num, "batch_num": batch_num,
"total_batches": total_batches "total_batches": total_batches
} }
server.send_sync("executed", message, server.client_id) server.send_sync("executed", message, server.client_id)
all_outputs.append(output)
all_outputs_ui.append(output_ui)
return all_outputs, all_outputs_ui return all_outputs, all_outputs_ui
def recursive_execute(server, prompt, outputs, current_item, extra_data, executed, prompt_id, outputs_ui): def recursive_execute(server, prompt, outputs, current_item, extra_data, executed, prompt_id, outputs_ui):

View File

@ -355,32 +355,30 @@ export class ComfyApp {
if (!this.flags.collapsed) { if (!this.flags.collapsed) {
// Outputs returned by the frontend for each node are a list, one for each combinatorial batch run. // Outputs returned by the frontend for each node are a list, one for each combinatorial batch run.
// With no combinatorial outputs, it's a list of length 1. // With no combinatorial outputs, it's a list of length 1.
// For now select only the first batch output. const outputs = app.nodeOutputs[this.id + ""]
const batchOutputs = app.nodeOutputs[this.id + ""]; if (outputs && this.batchOutputs !== outputs) {
if (batchOutputs && batchOutputs.length > 0) { this.batchOutputs = outputs;
const output = batchOutputs[0]; const batchImages = outputs.filter(Boolean).flatMap(o => o.images || []);
if (output && output.images) { if (this.images !== batchImages) {
if (this.images !== output.images) { this.images = batchImages;
this.images = output.images; this.imgs = null;
this.imgs = null; this.imageIndex = null;
this.imageIndex = null; Promise.all(
Promise.all( batchImages.map((src) => {
output.images.map((src) => { return new Promise((r) => {
return new Promise((r) => { const img = new Image();
const img = new Image(); img.onload = () => r(img);
img.onload = () => r(img); img.onerror = () => r(null);
img.onerror = () => r(null); img.src = "/view?" + new URLSearchParams(src).toString();
img.src = "/view?" + new URLSearchParams(src).toString(); });
}); })
}) ).then((imgs) => {
).then((imgs) => { if (this.images === batchImages) {
if (this.images === output.images) { this.imgs = imgs.filter(Boolean);
this.imgs = imgs.filter(Boolean); this.setSizeForImage?.();
this.setSizeForImage?.(); app.graph.setDirtyCanvas(true);
app.graph.setDirtyCanvas(true); }
} });
});
}
} }
} }