Mask Input Switch JK๐
A/B your masks โ swap inpainting regions and attention masks with a checkbox
- mask_false
- mask_true
- mask_output
- boolean
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-Truereturns the "true" mask,Falsethe "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.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| boolean_value | BOOLEAN | false | Condition to select between inputs (True=mask_true, False=mask_false) |
| mask_false | MASK | Mask to return when condition is False | |
| mask_trueopt | MASK | Mask to return when condition is True (optional) |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| mask_output | MASK | โ |
| boolean | BOOLEAN | โ |