Nodes/ComfyUI-JakeUpgrade/Mask Input Switch JK๐Ÿ‰
ComfyUI Node

Mask Input Switch JK๐Ÿ‰

A/B your masks โ€” swap inpainting regions and attention masks with a checkbox

By jakechaiยทCreated 2 years agoยทUpdated 3 months agoยท 146
Mask Input Switch JK๐Ÿ‰
  • mask_false
  • mask_true
  • mask_output
  • boolean
โ—„boolean_valuefalseโ–บ

Masks are the "where do I edit" signal in ComfyUI - the region to inpaint, the area to denoise, the part of the image to protect. Mask Input Switch JK๐Ÿ‰ lets you park two MASK wires in the graph and pick between them with a boolean, so swapping inpainting regions or attention masks is a toggle instead of a rewiring session.

It's the mask member of JakeUpgrade's switch family. In the pack's inpainting and detailer workflows - which shuffle masks around constantly, from CLIPSeg output to SAM segments to hand-drawn regions - being able to flip between "use the detected mask" and "use my manual mask" is exactly the kind of switch that keeps a workflow shareable.

How it works

The familiar shape:

if mask_true is not None and boolean_value:
    return (mask_true, boolean_value)
else:
    return (mask_false, boolean_value)
  • boolean_value - True returns the "true" mask, False the "false" one.
  • mask_false - required, used when False.
  • mask_true - optional, used when True; unplugged = pass-through.

Outputs: mask_output (MASK) and boolean (echoed condition). MASK here is a single-channel float tensor - the same thing that comes out of any mask generator node and goes into Set Latent Noise Mask, the mask input on inpaint pipelines, or a VAE Encode with mask.

Where you'd use it

The classic case is inpaint A/B: "inpaint the whole detected region" vs "only the face region" - same pipeline, different mask, one toggle. Or compare an automatic mask (from SAM/CLIPSeg) against a hand-drawn one without unplugging either. It also shows up in composite workflows where a mask decides which image area feeds a second pass. If you've been toggling masks by reconnecting wires, this is the node that stops the fiddling.

Install

Part of ComfyUI-JakeUpgrade. ComfyUI Manager โ†’ search ComfyUI-JakeUpgrade, or:

cd ComfyUI/custom_nodes
git clone https://github.com/jakechai/ComfyUI-JakeUpgrade
cd ComfyUI-JakeUpgrade && pip install -r requirements.txt

No models to download - masks come from whatever generates them upstream (SAM, CLIPSeg, mask editors). Menu: ๐Ÿ‰ JK/๐Ÿ”€ Switch. The pack's standard notes apply: ignore the IPAdapter Plus conflict warning in Manager if you see it, and check config.ini if switch nodes are missing. One behavior to remember: a mask switch routes, it doesn't lazy-load - both mask generators run every execution, so it costs a little compute even when you only use one branch.

Category๐Ÿ‰ JK/๐Ÿ”€ Switch

Inputs (3)

NameTypeDefaultDescription
boolean_valueBOOLEANfalseCondition to select between inputs (True=mask_true, False=mask_false)
mask_falseMASKMask to return when condition is False
mask_trueoptMASKMask to return when condition is True (optional)

Outputs (2)

NameTypeDescription
mask_outputMASKโ€”
booleanBOOLEANโ€”