handle widget too

This commit is contained in:
MaraScott 2024-05-21 23:28:34 +02:00
parent 2831e1fb0d
commit ffd49186de
6 changed files with 41 additions and 31 deletions

View File

@ -47,8 +47,10 @@ MAX_RESOLUTION=16384
class CLIPTextEncode:
@classmethod
def INPUT_TYPES(s):
return {"required": {"text": ("STRING", {"multiline": True, "dynamicPrompts": True}), "clip": ("CLIP", )}}
return {"required": {"text": ("STRING", {"multiline": True, "dynamicPrompts": True, "label": "text"}), "clip": ("CLIP", {"label": "text"})}}
RETURN_TYPES = ("CONDITIONING",)
RETURN_NAMES = ("CONDITIONING",)
RETURN_LABELS = ("conditioning",)
FUNCTION = "encode"
CATEGORY = "conditioning"
@ -258,8 +260,10 @@ class ConditioningSetTimestepRange:
class VAEDecode:
@classmethod
def INPUT_TYPES(s):
return {"required": { "samples": ("LATENT", ), "vae": ("VAE", )}}
return {"required": { "samples": ("LATENT", { "label": "latent"}), "vae": ("VAE", {"label": "vae"})}}
RETURN_TYPES = ("IMAGE",)
RETURN_NAMES = ("IMAGE",)
RETURN_LABELS = ("image",)
FUNCTION = "decode"
CATEGORY = "latent"
@ -492,6 +496,8 @@ class CheckpointLoader:
return {"required": { "config_name": (folder_paths.get_filename_list("configs"), ),
"ckpt_name": (folder_paths.get_filename_list("checkpoints"), )}}
RETURN_TYPES = ("MODEL", "CLIP", "VAE")
RETURN_NAMES = ("MODEL", "CLIP", "VAE")
RETURN_LABELS = ("model", "clip", "vae")
FUNCTION = "load_checkpoint"
CATEGORY = "advanced/loaders"
@ -504,9 +510,11 @@ class CheckpointLoader:
class CheckpointLoaderSimple:
@classmethod
def INPUT_TYPES(s):
return {"required": { "ckpt_name": (folder_paths.get_filename_list("checkpoints"), ),
return {"required": { "ckpt_name": (folder_paths.get_filename_list("checkpoints"), { "label": "model name"}),
}}
RETURN_TYPES = ("MODEL", "CLIP", "VAE")
RETURN_NAMES = ("MODEL", "CLIP", "VAE")
RETURN_LABELS = ("model", "clip", "vae")
FUNCTION = "load_checkpoint"
CATEGORY = "loaders"
@ -999,8 +1007,10 @@ class EmptyLatentImage:
def INPUT_TYPES(s):
return {"required": { "width": ("INT", {"default": 512, "min": 16, "max": MAX_RESOLUTION, "step": 8}),
"height": ("INT", {"default": 512, "min": 16, "max": MAX_RESOLUTION, "step": 8}),
"batch_size": ("INT", {"default": 1, "min": 1, "max": 4096})}}
"batch_size": ("INT", {"default": 1, "min": 1, "max": 4096, "label": "batch size"})}}
RETURN_TYPES = ("LATENT",)
RETURN_NAMES = ("LATENT",)
RETURN_LABELS = ("latent",)
FUNCTION = "generate"
CATEGORY = "latent"
@ -1322,20 +1332,22 @@ class KSampler:
@classmethod
def INPUT_TYPES(s):
return {"required":
{"model": ("MODEL",),
"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, "step":0.1, "round": 0.01}),
"sampler_name": (comfy.samplers.KSampler.SAMPLERS, ),
"scheduler": (comfy.samplers.KSampler.SCHEDULERS, ),
"positive": ("CONDITIONING", ),
"negative": ("CONDITIONING", ),
"latent_image": ("LATENT", ),
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
{"model": ("MODEL", { "label": "model" }),
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "label": "seed"}),
"steps": ("INT", {"default": 20, "min": 1, "max": 10000, "label": "steps"}),
"cfg": ("FLOAT", {"default": 8.0, "min": 0.0, "max": 100.0, "step":0.1, "round": 0.01, "label": "steps"}),
"sampler_name": (comfy.samplers.KSampler.SAMPLERS, { "label": "sampler name" } ),
"scheduler": (comfy.samplers.KSampler.SCHEDULERS, { "label": "scheduler" } ),
"positive": ("CONDITIONING", { "label": "positive" }),
"negative": ("CONDITIONING", { "label": "negative" }),
"latent_image": ("LATENT", {"label": "latent"}),
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01, "label": "denoise"}),
}
}
RETURN_TYPES = ("LATENT",)
RETURN_NAMES = ("LATENT",)
RETURN_LABELS = ("latent",)
FUNCTION = "sample"
CATEGORY = "sampling"
@ -1437,7 +1449,7 @@ class PreviewImage(SaveImage):
@classmethod
def INPUT_TYPES(s):
return {"required":
{"images": ("IMAGE", ), },
{"images": ("IMAGE", {"label": "image"}), },
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
}

View File

@ -394,6 +394,7 @@ class PromptServer():
info['output'] = obj_class.RETURN_TYPES
info['output_is_list'] = obj_class.OUTPUT_IS_LIST if hasattr(obj_class, 'OUTPUT_IS_LIST') else [False] * len(obj_class.RETURN_TYPES)
info['output_name'] = obj_class.RETURN_NAMES if hasattr(obj_class, 'RETURN_NAMES') else info['output']
info['output_label'] = obj_class.RETURN_LABELS if hasattr(obj_class, 'RETURN_LABELS') else info['output_name']
info['name'] = node_class
info['display_name'] = nodes.NODE_DISPLAY_NAME_MAPPINGS[node_class] if node_class in nodes.NODE_DISPLAY_NAME_MAPPINGS.keys() else node_class
info['description'] = obj_class.DESCRIPTION if hasattr(obj_class,'DESCRIPTION') else ''

View File

@ -75,7 +75,7 @@ function convertToInput(node, widget, config) {
const sz = node.size;
node.addInput(widget.name, type, {
widget: { name: widget.name, [GET_CONFIG]: () => config },
label: widget.element?.placeholder ? widget.element?.placeholder : widget.name
label: widget.element?.placeholder || widget?.label || widget.name
});
for (const widget of node.widgets) {
@ -290,14 +290,14 @@ app.registerExtension({
}
if (w.type === CONVERTED_TYPE) {
toWidget.push({
content: `Convert ${w.name} to widget`,
content: `Convert '${w?.label || w.name}' to widget`,
callback: () => convertToWidget(this, w),
});
} else {
const config = getConfig.call(this, w.name) ?? [w.type, w.options || {}];
if (isConvertableWidget(w, config)) {
toInput.push({
content: `Convert ${w.name} to input`,
content: `Convert '${w?.label || w.name}' to input`,
callback: () => convertToInput(this, w, config),
});
}

View File

@ -3758,6 +3758,7 @@
var w = {
type: type.toLowerCase(),
name: name,
label: options?.label || name,
value: value,
callback: callback,
options: options || {}

View File

@ -1676,15 +1676,8 @@ export class ComfyApp {
for (const o in nodeData["output"]) {
let output = nodeData["output"][o];
if(output instanceof Array) output = "COMBO";
let outputName = output;
let outputLabel = outputName;
if(nodeData["output_name"][o] instanceof Array) {
outputName = nodeData["output_name"][o][0] || output;
outputLabel = nodeData["output_name"][o][1]
} else {
outputName = nodeData["output_name"][o] || output;
outputLabel = outputName
}
const outputName = nodeData["output_name"][o] || output;
const outputLabel = nodeData["output_label"][o] || outputName;
const outputShape = nodeData["output_is_list"][o] ? LiteGraph.GRID_SHAPE : LiteGraph.CIRCLE_SHAPE ;
this.addOutput(outputName, output, { shape: outputShape, label: outputLabel });
}

View File

@ -8,7 +8,7 @@ export function updateControlWidgetLabel(widget) {
if (controlValueRunBefore) {
[find, replacement] = [replacement, find]
}
widget.label = (widget.label ?? widget.name).replace(find, replacement);
widget.label = (widget.label ?? widget.name).replace(find, replacement).replace(/_/g, " ");
}
const IS_CONTROL_WIDGET = Symbol();
@ -222,6 +222,8 @@ function createIntWidget(node, inputName, inputData, app, isSeedInput) {
let widgetType = isSlider(inputData[1]["display"], app);
const { val, config } = getNumberDefaults(inputData, 1, 0, true);
Object.assign(config, { precision: 0 });
const inputLabel = inputData[1]?.label || inputName;
Object.assign(config, { label: inputLabel });
return {
widget: node.addWidget(
widgetType,
@ -366,7 +368,8 @@ export const ComfyWidgets = {
if (inputData[1] && inputData[1].default) {
defaultValue = inputData[1].default;
}
const res = { widget: node.addWidget("combo", inputName, defaultValue, () => {}, { values: type }) };
const inputLabel = inputData[1]?.label || inputName
const res = { widget: node.addWidget("combo", inputName, defaultValue, () => {}, { values: type, label: inputLabel }) };
if (inputData[1]?.control_after_generate) {
res.widget.linkedWidgets = addValueControlWidgets(node, res.widget, undefined, undefined, inputData);
}