Nodes/SaltAI-Open-Resources/Batch Image CLIPSeg Masking
ComfyUI Node

Batch Image CLIPSeg Masking

Mask a whole batch from a text prompt

By get-salt-AI·Created 2 years ago·Updated 2 years ago· 84
Batch Image CLIPSeg Masking
  • images
  • clipseg_model
  • masks
  • mask_images
text

Drawing a mask by hand is fine for one image. It's miserable for a batch of fifty. SaltCLIPSegMasking skips the drawing entirely - you type what you want masked, in plain English, and CLIPSeg finds it across every image in the batch in one pass.

What CLIPSeg actually is

CLIPSeg is a zero-shot, text-conditioned segmentation model - it was never trained on "car" or "person" as fixed classes the way older segmentation models were. Instead it learned to line up image regions with arbitrary text, so you can type something as specific as "red umbrella" or "the dog's left ear" and get a plausible mask back, with no per-class training required. It's been floating around the ComfyUI ecosystem since one of the earliest standalone implementations (biegert/ComfyUI-CLIPSeg) showed up specifically to automate mask-drawing for batch inpainting - the exact problem this Salt node solves, just batched properly.

The inputs and outputs that matter

You give it images (your batch) and text - a single text string describing what to mask, applied across the whole batch. There's an optional clipseg_model input typed CLIPSEG_MODEL; leave it disconnected and the node loads its own default CLIPSeg checkpoint automatically the first time it runs (that first run will pause briefly while the model downloads). Wire in a loader only if you specifically need a different checkpoint.

Two outputs come back: masks - the actual MASK data you'll feed into other nodes - and mask_images, a visual IMAGE version of the same masks so you can actually look at what got selected before you commit to using it downstream. Always eyeball mask_images at least once per batch; CLIPSeg is good, not perfect, and a mask that's subtly wrong on one image out of fifty is exactly the kind of thing that's invisible until your inpaint comes back looking wrong.

Where it fits

This is the auto-masking half of the classic "mask, process, stitch" pipeline that dominates modern inpainting work - you generate the mask here, refine it if needed, then hand it to a crop/inpaint/stitch chain (this pack's own SaltImagePasteCrop handles the paste-back half). Because it works on batches with one shared text prompt, it's genuinely good for processing a whole folder of similar shots - same subject type, same thing you want masked - in one node instead of one CLIPSeg call per image.

Installing it

ComfyUI Manager: search SaltAI-Open-Resources. Manual install:

cd ComfyUI/custom_nodes
git clone https://github.com/get-salt-AI/SaltAI

Restart ComfyUI. The pack's README doesn't spell out extra pip installs, but CLIPSeg pulls in the Hugging Face transformers stack under the hood - if the node fails to import after cloning, that's the first thing to check for (a missing or outdated transformers), and the repo's own requirements.txt is the fix if pip didn't grab it automatically.

Common issues

CLIPSeg masks are inherently coarse - soft-edged blobs, not pixel-precise cutouts. That's not a bug, it's the tradeoff for not needing any training or manual drawing. If you need a tighter mask, chain the output through this pack's mask filters: SaltMaskThresholdRegion to binarize it, SaltMaskErodeRegion to pull the edges in off any bleed, SaltMaskSmoothRegion if you then want a soft feather back for compositing. Vague text prompts give vague masks - "the subject" works worse than "the woman's jacket." And because the text applies to every image in the batch identically, this node assumes some consistency across your batch; if image 30 doesn't contain whatever you described, you'll get a near-empty mask for it rather than an error, so check mask_images rather than assuming every frame worked.

CategorySALT/Masking

Inputs (3)

NameTypeDefaultDescription
imagesIMAGE
textSTRING
clipseg_modeloptCLIPSEG_MODEL

Outputs (2)

NameTypeDescription
masksMASK
mask_imagesIMAGE