Nodes/Nodes for use with real-time applications of ComfyUI/D Type Converter πŸ•’πŸ…‘πŸ…£πŸ…
ComfyUI Node

D Type Converter πŸ•’πŸ…‘πŸ…£πŸ…

When a Node Screams About Mask Dtype, This Is the Two-Second Fix

By ryanontheinsideΒ·Created 2 years agoΒ·Updated about a year agoΒ· 82
D Type Converter πŸ•’πŸ…‘πŸ…£πŸ…
  • mask
  • MASK
β—„dtypeβ–Ύβ–Ί

Every once in a while a node in your graph throws a fit because the mask you're feeding it isn't the dtype it expects. Maybe a custom inpainting node wants uint8, maybe something from another pack is doing float math and can't handle your 8-bit mask, maybe you're shuffling tensors around and just need them consistent. D Type Converter is the smallest possible fix for that: it takes a MASK and converts it between float16, uint8, float32, and float64. That's it. That's the node.

Which sounds trivial, and mostly is - but the conversion details matter more than they look. Masks in ComfyUI are conventionally float32 in the 0–1 range, where 0 is transparent and 1 is opaque. D Type Converter respects that convention in both directions: converting to uint8 scales by 255 and rounds (so a 1.0 mask becomes 255), and converting from uint8 normalizes back (255 becomes 1.0). That's the behavior you want. A naive cast that ignored the 0–255 vs 0–1 difference would hand you a mask that's either invisible or fully opaque, and this node is careful not to do that.

For float-to-float conversions (float32 β†’ float16 or float64), it's a straight cast - no scaling, because those all share the 0–1 interpretation. So the practical upshot is: you can move a mask between the "everything in this pack is float" world and the "this random node wants uint8" world without ever thinking about whether your values mean something different now.

Inputs and output

  • mask - any MASK. This node explicitly accepts only masks, not images, so don't try to convert an IMAGE with it.
  • dtype - one of float16, uint8, float32, float64.

Output: a single MASK in the requested dtype.

Install

It lives in ryanontheinside/ComfyUI_RealtimeNodes, alongside the real-time control nodes it's named after. ComfyUI Manager (search "Control Nodes" or "RealtimeNodes") or:

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

When you'll actually use it

Honestly? Not often. This is a utility you reach for when something breaks, not a node you build a workflow around - most of the time ComfyUI's own plumbing handles the casting for you. Where it earns its keep is in real-time pipelines, where you're shoving masks between an optimization pass and a node that's pickier than it should be, or when you want float16 to cut memory on a tight per-frame loop. It's also a decent debugging tool: if a mask "looks wrong," run it through to uint8 and you'll see exactly what downstream is receiving. Keep it in the back of your toolbox; it's not exciting, but it's exactly the node you'll be glad exists at 2am.

Categoryutils

Inputs (2)

NameTypeDefaultDescription
maskMASKβ€”
dtypeCOMBO4 options: float16, uint8, float32, float64

Outputs (1)

NameTypeDescription
MASKMASKβ€”