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:
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
if server.client_id is not None:
message = {
"node": unique_id,
"output": output_ui,
"output": all_outputs_ui, # list of outputs so far
"prompt_id": prompt_id,
"batch_num": batch_num,
"total_batches": total_batches
}
server.send_sync("executed", message, server.client_id)
all_outputs.append(output)
all_outputs_ui.append(output_ui)
return all_outputs, all_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) {
// 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.
// For now select only the first batch output.
const batchOutputs = app.nodeOutputs[this.id + ""];
if (batchOutputs && batchOutputs.length > 0) {
const output = batchOutputs[0];
if (output && output.images) {
if (this.images !== output.images) {
this.images = output.images;
this.imgs = null;
this.imageIndex = null;
Promise.all(
output.images.map((src) => {
return new Promise((r) => {
const img = new Image();
img.onload = () => r(img);
img.onerror = () => r(null);
img.src = "/view?" + new URLSearchParams(src).toString();
});
})
).then((imgs) => {
if (this.images === output.images) {
this.imgs = imgs.filter(Boolean);
this.setSizeForImage?.();
app.graph.setDirtyCanvas(true);
}
});
}
const outputs = app.nodeOutputs[this.id + ""]
if (outputs && this.batchOutputs !== outputs) {
this.batchOutputs = outputs;
const batchImages = outputs.filter(Boolean).flatMap(o => o.images || []);
if (this.images !== batchImages) {
this.images = batchImages;
this.imgs = null;
this.imageIndex = null;
Promise.all(
batchImages.map((src) => {
return new Promise((r) => {
const img = new Image();
img.onload = () => r(img);
img.onerror = () => r(null);
img.src = "/view?" + new URLSearchParams(src).toString();
});
})
).then((imgs) => {
if (this.images === batchImages) {
this.imgs = imgs.filter(Boolean);
this.setSizeForImage?.();
app.graph.setDirtyCanvas(true);
}
});
}
}