Load CLIPSeg model
Load CLIPSeg, the 'make a mask from a sentence' model
- ui_widget
- processor
- model
Some masks you can paint. Some you'd rather describe. LF_LoadCLIPSegModel is the loader for the CLIPSeg family - the zero-shot text-to-mask models that turn "give me a mask of the person" into an actual mask, no box-drawing, no SAM click-loop. It's the configuration node that feeds the other half of the pair, LF_CreateMask, which is where the prompt goes in and the mask comes out.
CLIPSeg is the same family of targeted masking that the background-removal playbook calls "GroundingDINO for the box, SAM for the mask" - except CLIPSeg skips the box entirely and predicts the segmentation from text directly. It's lighter and less precise than the DINO+SAM chain, but for "mask the foreground person" or "mask just the red car" it's often enough, and it's a single model rather than two.
How it works
Two inputs:
model_id(defaultCIDAS/clipseg-rd64-refined) - the HuggingFace model to pull. The default is the standard general-purpose CLIPSeg; it's small (tens of MB) and downloads on first load.folder(defaultclip_vision) - which ComfyUI folder the model is saved into, via the standardfolder_pathsmechanism. Keep it inside the ComfyUI directory or the loader can't resolve it.
The node checks whether the model is already cached and skips the download if so. Outputs are the two objects LF_CreateMask needs: processor (the CLIPSegProcessor) and model (the segmentation model), wired into that node's processor and model inputs respectively.
Installing it
Part of the lf-nodes pack, so the install is the pack install:
cd ComfyUI/custom_nodes
git clone https://github.com/lucafoscili/lf-nodes
restart ComfyUI (or ComfyUI Manager → "LF Nodes"). The dependency that matters here is transformers, which the pack already lists in its requirements. The model itself is small - a quick first-run download, nothing like the multi-GB tagger or checkpoint downloads you'll see elsewhere in the suite.
Troubleshooting
- "Folder must be in the ComfyUI directory" - keep
folderset to a real ComfyUI folder likeclip_visionormodels/clip_vision; it has to resolve through ComfyUI's own folder system. - First load slow - that's the HF download. One time, then cached.
- Masks that don't look right - that's usually the thresholding in LF_CreateMask, not the model. Head over there and try
otsumode before blaming the load.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| folder | STRING | clip_vision | Folder to download the model to. This folder must be in the ComfyUI directory. |
| model_id | STRING | CIDAS/clipseg-rd64-refined | HuggingFace CLIPSeg model ID. |
| ui_widgetopt | LF_CODE | [object Object] | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| processor | CLIP_PROCESSOR | CLIPSeg processor. |
| model | CLIP_MODEL | CLIPSeg model. |