mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-05-07 07:42:32 +08:00
Change in random seed execution order, if a seed is marked as random, the value is been randomized before call, not after
This commit is contained in:
parent
bb1223d83f
commit
9de1535931
@ -285,7 +285,7 @@ app.registerExtension({
|
||||
}
|
||||
|
||||
if (widget.type === "number") {
|
||||
addRandomizeWidget(this, widget, "Random after every gen");
|
||||
addRandomizeWidget(this, widget, "Random every gen");
|
||||
}
|
||||
|
||||
// When our value changes, update other widgets to reflect our changes
|
||||
|
||||
@ -842,6 +842,22 @@ class ComfyApp {
|
||||
|
||||
async queuePrompt(number, batchCount = 1) {
|
||||
for (let i = 0; i < batchCount; i++) {
|
||||
|
||||
const workflow = this.graph.serialize();
|
||||
|
||||
for (const n of workflow.nodes) {
|
||||
const node = graph.getNodeById(n.id);
|
||||
if (node.widgets) {
|
||||
for (const widget of node.widgets) {
|
||||
// Allow widgets to run callbacks after a prompt has been queued
|
||||
// e.g. random seed after every gen
|
||||
if (widget.beforeQueued) {
|
||||
widget.beforeQueued();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const p = await this.graphToPrompt();
|
||||
|
||||
try {
|
||||
@ -851,19 +867,6 @@ class ComfyApp {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const n of p.workflow.nodes) {
|
||||
const node = graph.getNodeById(n.id);
|
||||
if (node.widgets) {
|
||||
for (const widget of node.widgets) {
|
||||
// Allow widgets to run callbacks after a prompt has been queued
|
||||
// e.g. random seed after every gen
|
||||
if (widget.afterQueued) {
|
||||
widget.afterQueued();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.canvas.draw(true, true);
|
||||
await this.ui.queue.update();
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ export function addRandomizeWidget(node, targetWidget, name, defaultValue = fals
|
||||
serialize: false, // Don't include this in prompt.
|
||||
});
|
||||
|
||||
randomize.afterQueued = () => {
|
||||
randomize.beforeQueued = () => {
|
||||
if (randomize.value) {
|
||||
const min = targetWidget.options?.min;
|
||||
let max = targetWidget.options?.max;
|
||||
@ -32,12 +32,13 @@ export function addRandomizeWidget(node, targetWidget, name, defaultValue = fals
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return randomize;
|
||||
}
|
||||
|
||||
function seedWidget(node, inputName, inputData) {
|
||||
const seed = ComfyWidgets.INT(node, inputName, inputData);
|
||||
const randomize = addRandomizeWidget(node, seed.widget, "Random seed after every gen", true);
|
||||
const randomize = addRandomizeWidget(node, seed.widget, "Random seed every gen", true);
|
||||
|
||||
seed.widget.linkedWidgets = [randomize];
|
||||
return { widget: seed, randomize };
|
||||
|
||||
Loading…
Reference in New Issue
Block a user