Nodes/ComfyUI-YogurtSa2VA/Yogurt Sa2VA Image Segmentation
ComfyUI Node

Yogurt Sa2VA Image Segmentation

Describe the object, get the mask — no boxes, no DINO

By yogurt7771·Created 4 months ago·Updated 4 months ago· 0
Yogurt Sa2VA Image Segmentation
  • sa2va_model
  • image
  • text_output
  • masks
segmentation_promptPlease provide segmentation masks for all objects.
threshold0.50
morphnone
erode_kernel3
dilate_kernel3
iterations1

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/closing to smooth noise, erode/dilate to shrink or grow, with erode_kernel/dilate_kernel/iterations controlling how aggressive. none is 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) and masks (MASK batch).

Wire masks into InvertMaskJoin 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 - bitsandbytes not installed; install it or turn use_8bit off 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.

CategoryYogurtSa2VA

Inputs (8)

NameTypeDefaultDescription
sa2va_modelYOGURT_SA2VA_MODEL
imageIMAGEInput image to segment. Should be in RGB format.
segmentation_promptSTRINGPlease provide segmentation masks for all objects.Text prompt describing what objects to segment in the image.
thresholdFLOAT0.500–1Threshold for converting probability masks to binary masks.
morphCOMBOnone5 options: none, opening, closing, erode, dilate
erode_kernelINT31–50
dilate_kernelINT31–50
iterationsINT11–10

Outputs (2)

NameTypeDescription
text_outputSTRING
masksMASK