Mask To Float
Turn a mask batch into numbers AnimateDiff understands
- mask
- floats
Masks and floats live in different worlds in ComfyUI. Masks are spatial - a 2D image of coverage, 0 to 1 per pixel. Floats are temporal - one number per frame, which is exactly what motion schedulers and weight curves want. Mask To Float is the bridge: it collapses each mask in a batch down to a single number, so something frame-based can react to something image-based.
The mechanism
You feed in a MASK - a single mask or a batch of them. For each mask, the node computes the mean of every pixel value. A mostly-white mask averages near 1.0; a mostly-black one near 0.0; a half-covered mask lands around 0.5. The output is a FLOATS list with exactly one float per mask, in order.
That's the entire mechanism, and it's why the node is useful rather than gimmicky: if you have a sequence of masks - say, a mask that grows or shrinks over frames, or a moving subject's silhouette - the mean-per-mask gives you a smooth 0-to-1 curve that tracks "how much is covered" over time. Wire that into the rest of the Yvann pipeline (or any float consumer) and your animation strength follows the mask's evolution.
Where you'd reach for it
The intended use, per the pack, is turning mask data into weights for animation. A few concrete patterns:
- Scheduling with AnimateDiff - feed a time-varying mask batch (from a moving subject, or a keyframed mask) through this node, then into the pack's Edit Audio Weights or straight to a multival, and motion strength follows the mask.
- Measuring coverage over time - "how much of the frame is this thing occupying at each frame" is a genuinely useful signal for driving cut timing or weight ramps.
- Batch bookkeeping - collapse a big mask batch into a quick numeric summary you can eyeball or feed into logic.
Gotchas
The mean collapses everything spatial into a single number, so it's a blunt instrument. A small bright spot in a mostly-black mask and a big soft glow will both average to similar values - you lose all shape information. If you need per-region or per-channel detail, this isn't the node; it's for "overall coverage as a curve," nothing finer.
The output is a list (the pack's FLOATS type), not a single scalar - so downstream expect a per-frame value. And if you ever need the reverse direction (float back to mask), the pack author's note points you to ComfyUI-KJNodes, which has float-to-mask utilities. This node is the one-way trip.
Install
Same pack, same drill:
cd ComfyUI/custom_nodes
git clone https://github.com/yvann-ba/ComfyUI_Yvann-Nodes
or ComfyUI Manager → search ComfyUI_Yvann-Nodes → install → restart. It's pure torch mean math - no model, no download, instant even on long batches.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | Batch of masks to convert to mean float values |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| floats | FLOATS | — |