Mask Ops
Turn a text prompt into a mask, then level, grow, blur and split it
- image
- mask
- mask_image
- mask
- mask mapping
Mask Ops is the Swiss-army knife at the front of ComfyI2I's pipeline, and it does two genuinely different jobs. First, the party trick: it can create a mask straight from a text prompt - type "face" and it segments the face out of your image, no manual painting. Second, the utility job: hand it any existing mask and it runs the whole classic mask-operation chain on it - levels, erode/dilate, blur, invert, channel pick, blend - until the mask is exactly what your inpainting needs. If you're wiring up the pack's crop-inpaint-paste loop, this is where masks get born and cleaned up.
How it works
Flip use_text to 1 and the node loads CLIPSeg (CIDAS/clipseg-rd64-refined from HuggingFace) and segments your image by whatever's in text. CLIPSeg output is rough, which is what text_sigma (default 30) is for - it smooths the messy result into a usable mask. With use_text at 0 it takes your mask input instead (or builds a full-image mask if you give it nothing), then everything runs through the same operation chain: shrink_grow erodes (negative) or dilates (positive) it, invert flips it, blend_percentage blends the solid mask with a black-and-white version of the underlying image, black_level/mid_level/white_level remap the mask levels, channel picks which RGB channel of the image becomes the mask, and blur_radius feathers the edges. Finally separate_mask decides whether every mask island stays in one image (0) or splits into its own individual masks (1).
The inputs that actually matter
use_text/text- 0 for an existing mask, 1 to mask by prompt.textis a plain string; "face", "car", "sky" all work.text_sigma- smooths CLIPSeg's rough output. If the text mask comes out blobby or patchy, this is your first knob.separate_mask- 0 keeps all islands together (required for feeding Color Transfer), 1 splits them per island with a mapping for batch pipelines.shrink_grow- grow or shrink the mask before you use it. Inpaint masks usually want a little growth so the edit has room to blend.blur_radius- feather the mask edges. More feather = softer seams when you paste the edit back.mask- the optional MASK input whenuse_textis 0.
Outputs are three: mask_image (the mask rendered as an IMAGE), mask (a MASK), and mask mapping (a MASK_MAPPING for batch work). The MASK wires straight into Inpaint Segments, Color Transfer, or VAE Encode; the mapping is there for the batch path.
Install
The pack ships with ComfyUI Manager - search "ComfyI2I" (or ManglerFTW/ComfyI2I). Manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/ManglerFTW/ComfyI2I
cd ComfyI2I
pip install -r requirements.txt
Restart ComfyUI; it lives under the I2I category. Two dependency traps here, both real and both in the source code. First, transformers is needed for text masking but is not in requirements.txt - if use_text throws a ModuleNotFoundError, run pip install transformers. Second, the CLIPSeg model downloads from HuggingFace into ComfyUI/models/clipseg on first text-mask use - a few hundred MB that appears out of nowhere the first time. The node will also quietly pip install scipy at runtime if it's missing, which is quirky but works. And yes, that requirements file still drags in tensorflow and scikit-image that nothing imports - ignore the bloat, or trim the list yourself.
Common issues
- Text masking fails on import.
transformersisn't installed.pip install transformers, restart, done. - Prompt mask looks wrong or rough. CLIPSeg is a small model from 2022; it's not magic. Try a more concrete noun ("window" instead of "that glass thing"), then massage with
text_sigma,shrink_growandblur_radius. - Feeding the mask to Color Transfer recolors everything. You left
separate_maskat 1. Set it to 0 - the README is explicit that Color Transfer expects the unseparated output. - Hand-drawn alternative: the pack also ships ComfyShop, a paint tool you reach by right-clicking any image node that outputs IMAGE + MASK. It writes greyscale painting to the MASK output and color to the IMAGE output, with undo, zoom and brush controls.
Mask Ops is the one node in this pack you'll keep reaching for even if you never use the rest of the pipeline. The prompt-to-mask trick alone replaces a lot of manual painting for batch work, and the mask-cleaning chain is faster than stringing together five separate core nodes. The pack's been dormant since late 2023, but this is old, stable functionality - it just works.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| text | STRING | — | |
| separate_mask | INT | 00–1 | — |
| text_sigma | INT | 300–150 | — |
| use_text | INT | 00–1 | — |
| blend_percentage | FLOAT | 0.000–1 | — |
| black_level | FLOAT | 0.00–255 | — |
| mid_level | FLOAT | 127.50–255 | — |
| white_level | FLOAT | 255.00–255 | — |
| channel | COMBO | 3 options: red, green, blue | |
| shrink_grow | INT | 0-128–128 | — |
| invert | INT | 00–1 | — |
| blur_radius | FLOAT | 5.00–1024 | — |
| maskopt | MASK | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| mask_image | IMAGE | — |
| mask | MASK | — |
| mask mapping | MASK_MAPPING | — |