mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-18 19:57:04 +08:00
Cleanups.
This commit is contained in:
parent
0fb9dc9732
commit
ca8e5cb5db
4
nodes.py
4
nodes.py
@ -748,7 +748,7 @@ class KSampler:
|
||||
def INPUT_TYPES(s):
|
||||
return {"required":
|
||||
{"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}),
|
||||
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0}),
|
||||
"sampler_name": (comfy.samplers.KSampler.SAMPLERS, ),
|
||||
@ -773,7 +773,7 @@ class KSamplerAdvanced:
|
||||
return {"required":
|
||||
{"model": ("MODEL",),
|
||||
"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}),
|
||||
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0}),
|
||||
"sampler_name": (comfy.samplers.KSampler.SAMPLERS, ),
|
||||
|
||||
@ -5,14 +5,9 @@ const CONVERTED_TYPE = "converted-widget";
|
||||
const VALID_TYPES = ["STRING", "combo", "number"];
|
||||
|
||||
function isConvertableWidget(widget, config) {
|
||||
if (widget.name == "control_after_generate" ||
|
||||
widget.name == "batch_size")
|
||||
widget.allowConvertToInput = false;
|
||||
else
|
||||
return VALID_TYPES.includes(widget.type) || VALID_TYPES.includes(config[0]);
|
||||
return VALID_TYPES.includes(widget.type) || VALID_TYPES.includes(config[0]);
|
||||
}
|
||||
|
||||
|
||||
function hideWidget(node, widget, suffix = "") {
|
||||
widget.origType = widget.type;
|
||||
widget.origComputeSize = widget.computeSize;
|
||||
@ -276,40 +271,22 @@ app.registerExtension({
|
||||
}
|
||||
|
||||
let widget;
|
||||
|
||||
// ComfyWidgets allows a subtype of widgets which is defined by "<type>:<widgetName>"
|
||||
// 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;
|
||||
if (type in ComfyWidgets) {
|
||||
widget = (ComfyWidgets[type](this, "value", inputData, app) || {}).widget;
|
||||
} else {
|
||||
// we did not find a subtype, so proceed with "<type>" only
|
||||
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");
|
||||
}
|
||||
widget = this.addWidget(type, "value", null, () => {}, {});
|
||||
}
|
||||
|
||||
|
||||
if (node?.widgets && widget) {
|
||||
|
||||
const theirWidget = node.widgets.find((w) => w.name === widgetName);
|
||||
const theirWidget = node.widgets.find((w) => w.name === widgetName);
|
||||
if (theirWidget) {
|
||||
widget.value = theirWidget.value;
|
||||
}
|
||||
}
|
||||
|
||||
if (widget.type === "number") {
|
||||
addValueControlWidget(this, widget, "fixed");
|
||||
}
|
||||
|
||||
// When our value changes, update other widgets to reflect our changes
|
||||
// e.g. so LoadImage shows correct image
|
||||
|
||||
@ -944,8 +944,9 @@ class ComfyApp {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.#invokeExtensions("loadedGraphNode", node);
|
||||
}
|
||||
|
||||
this.#invokeExtensions("loadedGraphNode", node);
|
||||
}
|
||||
|
||||
if (missingNodeTypes.length) {
|
||||
|
||||
@ -56,7 +56,7 @@ export const defaultGraph = {
|
||||
],
|
||||
outputs: [{ name: "LATENT", type: "LATENT", links: [7], slot_index: 0 }],
|
||||
properties: {},
|
||||
widgets_values: [8008135, true, 20, 8, "euler", "normal", 1],
|
||||
widgets_values: [156680208700286, true, 20, 8, "euler", "normal", 1],
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
|
||||
@ -17,32 +17,29 @@ export function addValueControlWidget(node, targetWidget, defaultValue = "random
|
||||
});
|
||||
valueControl.afterQueued = () => {
|
||||
|
||||
var v = valueControl.value;
|
||||
var v = valueControl.value;
|
||||
|
||||
let min = targetWidget.options?.min;
|
||||
let max = targetWidget.options?.max;
|
||||
let range = Math.max(min, max);
|
||||
let min = targetWidget.options.min;
|
||||
let max = targetWidget.options.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
|
||||
if (min != null && max != null) {
|
||||
//adjust values based on valueControl Behaviour
|
||||
switch (v) {
|
||||
case "fixed":
|
||||
break;
|
||||
case "increment":
|
||||
targetWidget.value += targetWidget.options?.step / 10;
|
||||
break;
|
||||
case "decrement":
|
||||
targetWidget.value -= targetWidget.options?.step / 10;
|
||||
break;
|
||||
case "randomize":
|
||||
if (targetWidget.step == 64)
|
||||
targetWidget.value = Math.floor(Math.random() * range) * 64 + min;
|
||||
else
|
||||
targetWidget.value = parseFloat((Math.floor(Math.random() * ((range * 100) + 1)) / 100).toFixed(2));
|
||||
case "fixed":
|
||||
break;
|
||||
case "increment":
|
||||
targetWidget.value += targetWidget.options.step / 10;
|
||||
break;
|
||||
case "decrement":
|
||||
targetWidget.value -= targetWidget.options.step / 10;
|
||||
break;
|
||||
case "randomize":
|
||||
targetWidget.value = Math.floor(Math.random() * range) * (targetWidget.options.step / 10) + min;
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*check if values are over or under their respective
|
||||
* ranges and set them to min or max.*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user