ComfyUI Node Runs on cloud

Float To Mask

Turn a list of numbers into a batch of solid masks

By kijai·Created 3 years ago·Updated about 8 hours ago· 2,930
Float To Mask
    • MASK
    input_values0.00
    width100
    height100

    Sometimes the thing you actually have is a list of numbers - an amplitude curve, a manually typed schedule, values pulled out of some other node - and the thing you need is a mask, because that's the currency the node you want to use next actually accepts. FloatToMask is the bridge: hand it float values, get back a batch of flat, solid-value masks, one per number, sized however you need.

    It's a small node doing one obvious job, and its usefulness is entirely about what it unlocks downstream - anywhere a workflow expects a MASK input but what you're actually driving is a plain numeric schedule.

    How it works

    Each value in input_values becomes its own mask in the output batch, filled uniformly at that value across the whole width × height canvas - think of it as broadcasting one number into a same-colored image, then stacking those into a batch the same length as your float list. Feed it a single float and you get a single flat mask; feed it a list and the batch size follows the list's length automatically, no separate batch-size control to keep in sync.

    The inputs and outputs that matter

    • input_values (default 0) - the float or list of floats you're converting. This is the entire content of the node; everything else is just canvas size.
    • width and height (both default 100, minimum 1) - the pixel dimensions of every mask in the output batch. Match these to whatever your downstream node actually expects, since there's no auto-resize here.

    Output is a single MASK batch - wire it into anything that takes a mask and treats brightness as strength: a blend node, a compositing step, an amplitude-driven effect.

    How to install it

    Via ComfyUI Manager: search "KJNodes for ComfyUI," install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/kijai/ComfyUI-KJNodes
    pip install -r ComfyUI-KJNodes/requirements.txt
    

    then restart. This node has no extra dependencies of its own - it's arithmetic and tensor allocation, nothing more.

    Common issues & troubleshooting

    Your mask batch doesn't line up with your image batch. The batch size here is set entirely by however many values are in input_values - if that list is shorter or longer than the image/frame batch you're trying to pair it with, everything downstream that expects matched lengths will error or silently misalign. Count your floats before you wire this in.

    The output looks flat and boring - that's correct. This isn't a gradient or pattern generator; every pixel in a given mask is the same value. If you actually want a spatial gradient (varying across the image, not just across the batch), you want a different node in the pack - this one is strictly "one number in, one flat mask out," repeated per value.

    Values outside 0–1 do something unexpected downstream. Masks are conventionally read as 0–1 strength by most consuming nodes; if your float source produces values outside that range (a raw amplitude signal, for instance), normalize it before this node rather than after, or the "mask" will effectively clip or invert depending on what reads it next.

    CategoryKJNodes/masking/generate

    Inputs (3)

    NameTypeDefaultDescription
    input_valuesFLOAT0.00
    widthINT100
    heightINT100

    Outputs (1)

    NameTypeDescription
    MASKMASK