ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

Feature request: connectable ints/floats/strings

Open Maykeye opened this issue 2 years ago • 3 comments

Right now to edit width/height i need to manually edit two fields.

My idea was to make ConstInt node and to connect it to width and height node. Right now it's not possible.

(Also having ability to make integer/float nodes would allow to move Random seed after every generation to specialized seed node).

Maykeye avatar Mar 01 '23 13:03 Maykeye

I stuck this code in the nodes.py file:

class ConstFloat:
    @classmethod
    def INPUT_TYPES(cls):
        return {"required": {"n": ("FLOAT", {"multiline": True, "dynamic_prompt": True, "default": 1.0, "min": -512.0, "max": 512.0})}}

    RETURN_TYPES = ("FLOAT",)
    FUNCTION = "set_float"
    CATEGORY = "Constants"

    def set_float(self, n):
        return (n,)

class ConstInt:
    @classmethod
    def INPUT_TYPES(cls):
        return {"required": {"n": ("INT", {"multiline": True, "dynamic_prompt": True, "default": 1, "min": -512, "max": 512})}}

    RETURN_TYPES = ("INT",)
    FUNCTION = "set_int"
    CATEGORY = "Constants"

    def set_int(self, n):
        return (n,)

class ConstString:
    @classmethod
    def INPUT_TYPES(cls):
        return {"required": {"n": ("STRING", {"multiline": True, "dynamic_prompt": True, "default": ""})}}

    RETURN_TYPES = ("STRING",)
    FUNCTION = "set_string"
    CATEGORY = "Constants"

    def set_string(self, n):
        return (n,)

I stuck it in just above this "NODE_CLASS_MAPPINGS = { "KSampler": KSampler,...".

Then at the bottom of the NODE_CLASS_MAPPINGS list, I extended it with these:

    "ConstFloat": ConstFloat,
    "ConstInt": ConstInt,
    "ConstString": ConstString,

They seem to work fine so far. Likely my hacked together code could be improved, but this should get you started.

GrimblyGorn avatar Mar 13 '23 20:03 GrimblyGorn

Piggybacking on this idea, it would be great if these nodes had inputs and outputs for parameters like seed. That way, one sampler could generate a random seed and pass that on to additional samplers.

jordanbtucker avatar Mar 13 '23 23:03 jordanbtucker

Piggybacking on this idea, it would be great if these nodes had inputs and outputs for parameters like seed. That way, one sampler could generate a random seed and pass that on to additional samplers.

Yeah this is a important feature for like HR fix workflows to retain the overall theme without it going too rogue on HR pass.

WASasquatch avatar Mar 18 '23 07:03 WASasquatch

Fixed with: https://github.com/comfyanonymous/ComfyUI/pull/243

comfyanonymous avatar Mar 25 '23 05:03 comfyanonymous