Nodes/Masquerade Nodes/Mask By Text
ComfyUI Node Runs on cloud

Mask By Text

Mask anything by typing what you want, no painting

By BadCafeCode·Created 3 years ago·Updated 2 years ago· 481
Mask By Text
  • image
  • thresholded_mask
  • raw_mask
prompt
negative_prompt
precision0.50
normalize

Mask By Text is the reason Masquerade Nodes exists in the first place - the README calls it the "lynchpin" node, and it's not exaggerating. Instead of picking up a brush and painting a mask by hand, you type a word or phrase ("the sky", "her hat", "the red car") and the node figures out where that thing is in the image and hands you back a mask. No SAM, no bounding boxes, no clicking - just a text prompt in, a mask out.

Under the hood it runs ClipSeg, a small open-vocabulary segmentation model that pairs CLIP's text understanding with a lightweight decoder trained to predict pixel masks from a text query. It's not a detector in the SAM/GroundingDINO sense - it doesn't find object boundaries with pixel-perfect precision - it's closer to "wherever in this image the model thinks this text applies, light it up." That makes it fuzzier than a proper segmentation model but a lot faster to get something useful, which is exactly why it got adopted early: back when this pack came out, ClipSeg was one of the only ways to get text-prompted masking in ComfyUI at all, before SAM+GroundingDINO combos and the newer all-in-one packs made object-grounded masking a first-class, more precise workflow. If you're doing serious object-level masking today, that newer combo generally beats ClipSeg on accuracy - but for quick, rough selections without installing a detector stack, this node still does the job in one node.

The inputs that matter

  • image - the image to search.
  • prompt - one or more phrases to select, separated by |. Multiple prompts in one node saves you chaining several Mask By Text nodes together with a Combine Masks union afterward.
  • negative_prompt - same syntax, phrases to actively exclude.
  • precision (FLOAT, 0–1, default 0.5) - the threshold on the model's confidence before a pixel counts as "in" the mask. Higher is stricter.
  • normalize - stretches the result across the image's full value range. Try it off first; it's mainly useful when you're confident the concept is in the image but ClipSeg is being inconsistent about how strongly it responds to it.

There are two outputs, and the second one is easy to miss but genuinely useful: thresholded_mask is the ready-to-use binary-ish mask after precision and normalize are applied - this is what you wire into Cut By Mask or a sampler. raw_mask is ClipSeg's unprocessed 0.0–1.0 confidence map before thresholding, and it's the one to reach for if you want to compare two concepts rather than just mask one - average the raw output of two Mask By Text nodes with different prompts and you can tell which concept the model thinks is more strongly present.

Installing it

Mask By Text ships with Masquerade Nodes. Install via ComfyUI Manager (search "Masquerade Nodes") or cd ComfyUI/custom_nodes && git clone https://github.com/BadCafeCode/masquerade-nodes-comfyui, then restart. This is the one node in the pack that isn't actually dependency-free despite the README's framing - on first use it pip-installs the clipseg package straight from its GitHub source and downloads the ClipSeg checkpoint from a third-party university file host. Both happen automatically, but it means the first time you run this node, expect a pause while it fetches and caches things rather than running instantly.

Common issues

That first-run download is the thing most likely to trip you up, and it's worth knowing it's not hosted on HuggingFace or a CDN - it comes from a university file-sharing server, which occasionally means slower or flakier downloads than you'd expect from a normal model checkpoint, especially behind a restrictive network or a sandboxed/offline ComfyUI install where the node can't reach out and pip-install at all. If the node errors out on first use, check whether your environment allows outbound pip installs and downloads before assuming the node itself is broken. Once the package and weights are cached, subsequent runs are fast and don't re-download. On accuracy: if a mask comes back empty or covers the whole image, try loosening the prompt to something more literal ("person" instead of "the subject"), and remember precision is a blunt instrument - nudge it in small steps (0.4, 0.3) rather than jumping straight to zero, since ClipSeg's confidence maps are often continuous rather than cleanly separated.

CategoryMasquerade Nodes

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
promptSTRING
negative_promptSTRING
precisionFLOAT0.500–1
normalizeCOMBO2 options: no, yes

Outputs (2)

NameTypeDescription
thresholded_maskIMAGE
raw_maskIMAGE