Cleanups.

This commit is contained in:
comfyanonymous 2023-04-12 01:05:46 -04:00
parent 0fb9dc9732
commit ca8e5cb5db
5 changed files with 32 additions and 57 deletions

View File

@ -748,7 +748,7 @@ class KSampler:
def INPUT_TYPES(s): def INPUT_TYPES(s):
return {"required": return {"required":
{"model": ("MODEL",), {"model": ("MODEL",),
"seed": ("INT", {"default": 0, "min": 0, "max": 4294967294}), #"max": 0xffffffffffffffff}), "seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
"steps": ("INT", {"default": 20, "min": 1, "max": 10000}), "steps": ("INT", {"default": 20, "min": 1, "max": 10000}),
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0}), "cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0}),
"sampler_name": (comfy.samplers.KSampler.SAMPLERS, ), "sampler_name": (comfy.samplers.KSampler.SAMPLERS, ),
@ -773,7 +773,7 @@ class KSamplerAdvanced:
return {"required": return {"required":
{"model": ("MODEL",), {"model": ("MODEL",),
"add_noise": (["enable", "disable"], ), "add_noise": (["enable", "disable"], ),
"noise_seed": ("INT", {"default": 0, "min": 0, "max": 4294967294}), #"max": 0xffffffffffffffff}), "noise_seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
"steps": ("INT", {"default": 20, "min": 1, "max": 10000}), "steps": ("INT", {"default": 20, "min": 1, "max": 10000}),
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0}), "cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0}),
"sampler_name": (comfy.samplers.KSampler.SAMPLERS, ), "sampler_name": (comfy.samplers.KSampler.SAMPLERS, ),

View File

@ -5,14 +5,9 @@ const CONVERTED_TYPE = "converted-widget";
const VALID_TYPES = ["STRING", "combo", "number"]; const VALID_TYPES = ["STRING", "combo", "number"];
function isConvertableWidget(widget, config) { function isConvertableWidget(widget, config) {
if (widget.name == "control_after_generate" || return VALID_TYPES.includes(widget.type) || VALID_TYPES.includes(config[0]);
widget.name == "batch_size")
widget.allowConvertToInput = false;
else
return VALID_TYPES.includes(widget.type) || VALID_TYPES.includes(config[0]);
} }
function hideWidget(node, widget, suffix = "") { function hideWidget(node, widget, suffix = "") {
widget.origType = widget.type; widget.origType = widget.type;
widget.origComputeSize = widget.computeSize; widget.origComputeSize = widget.computeSize;
@ -276,40 +271,22 @@ app.registerExtension({
} }
let widget; let widget;
if (type in ComfyWidgets) {
// ComfyWidgets allows a subtype of widgets which is defined by "<type>:<widgetName>" widget = (ComfyWidgets[type](this, "value", inputData, app) || {}).widget;
// common example is "INT:seed"
// so let's check for those first
let combinedWidgetType = type + ":" + widgetName;
if (combinedWidgetType in ComfyWidgets) {
// widget = (ComfyWidgets[combinedWidgetType](this, "value", inputData, app) || {}).widget;
widget = (ComfyWidgets[combinedWidgetType](this, widgetName, inputData, app) || {}).widget;
} else { } else {
// we did not find a subtype, so proceed with "<type>" only widget = this.addWidget(type, "value", null, () => {}, {});
if (type in ComfyWidgets) {
widget = (ComfyWidgets[type](this, widgetName/*"value*"*/, inputData, app) || {}).widget;
} else {
widget = this.addWidget(type, widgetName /*"value"*/, null, () => { }, {});
}
if (widget.type === "number" &&
combinedWidgetType != "INT:seed" &&
combinedWidgetType != "INT:noise_seed" &&
widgetName != "start_at_step" &&
widgetName != "end_at_step") {
addValueControlWidget(this, widget, "fixed");
}
} }
if (node?.widgets && widget) { if (node?.widgets && widget) {
const theirWidget = node.widgets.find((w) => w.name === widgetName);
const theirWidget = node.widgets.find((w) => w.name === widgetName);
if (theirWidget) { if (theirWidget) {
widget.value = theirWidget.value; widget.value = theirWidget.value;
} }
} }
if (widget.type === "number") {
addValueControlWidget(this, widget, "fixed");
}
// When our value changes, update other widgets to reflect our changes // When our value changes, update other widgets to reflect our changes
// e.g. so LoadImage shows correct image // e.g. so LoadImage shows correct image

View File

@ -944,8 +944,9 @@ class ComfyApp {
} }
} }
} }
this.#invokeExtensions("loadedGraphNode", node);
} }
this.#invokeExtensions("loadedGraphNode", node);
} }
if (missingNodeTypes.length) { if (missingNodeTypes.length) {

View File

@ -56,7 +56,7 @@ export const defaultGraph = {
], ],
outputs: [{ name: "LATENT", type: "LATENT", links: [7], slot_index: 0 }], outputs: [{ name: "LATENT", type: "LATENT", links: [7], slot_index: 0 }],
properties: {}, properties: {},
widgets_values: [8008135, true, 20, 8, "euler", "normal", 1], widgets_values: [156680208700286, true, 20, 8, "euler", "normal", 1],
}, },
{ {
id: 8, id: 8,

View File

@ -17,32 +17,29 @@ export function addValueControlWidget(node, targetWidget, defaultValue = "random
}); });
valueControl.afterQueued = () => { valueControl.afterQueued = () => {
var v = valueControl.value; var v = valueControl.value;
let min = targetWidget.options?.min; let min = targetWidget.options.min;
let max = targetWidget.options?.max; let max = targetWidget.options.max;
let range = Math.max(min, max); // limit to something that javascript can handle
max = Math.min(1125899906842624, max);
min = Math.max(-1125899906842624, min);
let range = (max - min) / (targetWidget.options.step / 10);
//adjust values based on valueControl Behaviour //adjust values based on valueControl Behaviour
if (min != null && max != null) {
switch (v) { switch (v) {
case "fixed": case "fixed":
break; break;
case "increment": case "increment":
targetWidget.value += targetWidget.options?.step / 10; targetWidget.value += targetWidget.options.step / 10;
break; break;
case "decrement": case "decrement":
targetWidget.value -= targetWidget.options?.step / 10; targetWidget.value -= targetWidget.options.step / 10;
break; break;
case "randomize": case "randomize":
if (targetWidget.step == 64) targetWidget.value = Math.floor(Math.random() * range) * (targetWidget.options.step / 10) + min;
targetWidget.value = Math.floor(Math.random() * range) * 64 + min; default:
else
targetWidget.value = parseFloat((Math.floor(Math.random() * ((range * 100) + 1)) / 100).toFixed(2));
break; break;
default:
break;
}
} }
/*check if values are over or under their respective /*check if values are over or under their respective
* ranges and set them to min or max.*/ * ranges and set them to min or max.*/