Yogurt Sa2VA Image Segmentation
Describe the object, get the mask — no boxes, no DINO
- sa2va_model
- image
- text_output
- masks
This is the node that makes prompt-based segmentation feel like cheating: "the woman in the red dress on the right" and Sa2VA just... cuts her out. No Grounding DINO phrases, no SAM boxes, no second pass. The old Grounded SAM 2 / Grounding DINO pipeline fell apart on anything more specific than "dog on right" - it's a detection model, not a text understander. Sa2VA is a full vision-language model, so it actually parses a whole sentence and segments what you meant. That's the gap this node fills, and it's the reason Sa2VA got the community's attention in the first place.
Feed it a model object from Yogurt Sa2VA Model Loader and a single image, describe the target, and it returns two things: the model's text response and the masks.
How it works
The node takes your image, wraps the prompt as <image>..., and calls Sa2VA's predict_forward in a single pass. The model returns probability masks per detected object (it was fine-tuned on SAM2 outputs, so it natively emits masks - no separate detector). Then a few steps happen in node-land:
- threshold converts the probability mask to a binary mask - 0.5 default, raise it for stricter (smaller, harder) masks, lower it to catch soft edges.
- morph cleans up the binary result:
opening/closingto smooth noise,erode/dilateto shrink or grow, witherode_kernel/dilate_kernel/iterationscontrolling how aggressive.noneis fine for clean subjects. - Each object comes back as its own
MASK, stacked into a batch - so "all objects" gives you one mask per object, and you can process them independently downstream.
There's one honest caveat, straight from the README: the configurable threshold only truly works on the Qwen-series Sa2VA models (like the Qwen3-VL-4B default), which get a patched predict_forward that returns raw sigmoid probabilities. On InternVL or kumuji models the node falls back to the model's built-in binarization and the threshold slider goes quiet. If your slider seems to do nothing, that's why - it's not you.
Inputs and outputs in one breath
sa2va_model- from the Model Loader.image- RGB tensor, the thing to cut up.segmentation_prompt- describe it like you'd ask a person. Specific beats generic; "the wooden chair in the foreground" beats "chairs".threshold/morph/ kernels /iterations- mask binarization and cleanup, defaults are sensible.- Out:
text_output(STRING - the model's caption/answer) andmasks(MASK batch).
Wire masks into InvertMask → Join Image with Alpha for an instant transparent cutout, or straight into an inpainting node where you only want the masked region touched. The text_output is handy for agentic workflows where you want the model's reasoning recorded.
Install & the fine print
Same pack install as everything here: clone the repo into custom_nodes, pip install -r requirements.txt (transformers, qwen_vl_utils, pillow, numpy), restart. Models in ComfyUI/models/sa2va with a config.json, else transformers downloads them. Gotchas from the README that'll actually hit you:
- Dropdown empty after copying models - wrong structure (no
config.json) or ComfyUI not restarted. - 8-bit load fails -
bitsandbytesnot installed; install it or turnuse_8bitoff in the loader.
This node gives you masks, not mattes. Edges are object-level: good enough for inpainting and compositing a person, ragged on hair. If hair/fur/glass is your use case, skip to Yogurt Sa2VA Image Segmentation V2, which adds VITMatte refinement and gets you alpha-level edges.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| sa2va_model | YOGURT_SA2VA_MODEL | — | |
| image | IMAGE | Input image to segment. Should be in RGB format. | |
| segmentation_prompt | STRING | Please provide segmentation masks for all objects. | Text prompt describing what objects to segment in the image. |
| threshold | FLOAT | 0.500–1 | Threshold for converting probability masks to binary masks. |
| morph | COMBO | none | 5 options: none, opening, closing, erode, dilate |
| erode_kernel | INT | 31–50 | — |
| dilate_kernel | INT | 31–50 | — |
| iterations | INT | 11–10 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| text_output | STRING | — |
| masks | MASK | — |