Open-Vocabulary & Promptable Segmentation
Detecting objects named in text and segmenting anything from a click.
Ask a detector trained on COCO to find a "toy elephant" and it can only answer in its 80 classes. Replace its classifier by text embeddings and it can look for anything you can name; give a segmenter a click instead of a class and it can outline objects nobody labeled. Both moves trade a fixed label list for a prompt, and both raise the same questions: what the model actually learned, what it should do when a prompt is ambiguous, and how to evaluate a vocabulary that has no end.
What you’ll learn
- Turn a detector's classifier into text embeddings, and state the protocols (held-out classes, LVIS rare-category AP, what "zero-shot" excludes) that make open-vocabulary claims measurable.
- Compare how ViLD, OWL-ViT, GLIP, Grounding DINO and Detic bring language into detection, and what each choice costs.
- Prove that one output trained on ambiguous prompts converges to the average of the valid masks, and that a minimum-over-outputs loss makes several outputs specialize.
- Describe Segment Anything's promptable task, architecture and data engine, and SAM 2's streaming memory for video.
- Identify the limits: masks without semantics, fine structures, domain shift, and pipelines that compose a detector with a segmenter.
From a fixed list to any name
A detector's last layer is usually a matrix that scores a region's features against classes fixed at training time. Vision Transformers & Vision–Language Models showed that CLIP's zero-shot classifier is the same linear map with its rows written in words: is the unit text embedding of a prompt such as "a photo of a {class}." Open-vocabulary detectors move that classifier from whole images to regions. A region with unit embedding is scored against the text embeddings of whatever classes the user lists, plus a background embedding learned in training:
Localization is the easier half: proposal networks and box heads trained on some classes also find object-like regions of others. Naming them is the hard half, and measuring it needs categories held out from training. Zareian et al. (2021), who introduced the term open-vocabulary detection, trained with boxes for 48 COCO classes plus image–caption pairs and tested on 17 classes that had no boxes in training.
The standard benchmark became LVIS (Gupta, Dollár & Girshick, 2019), in its v1.0 release: 1,203 categories on COCO's images, grouped by how many training images contain them into frequent (more than 100), common (11 to 100) and rare (1 to 10), a long tail by design. Open-vocabulary training uses the 866 frequent and common categories, the 337 rare ones are held out as novel, and their AP, written AP, is the headline number. LVIS is federated: each image is checked only for some categories, marked present or verified absent, and detections of categories nobody checked in that image are not scored.
Where language meets the image
| Detector | Where boxes come from | How language enters | Names learned from |
|---|---|---|---|
| ViLD (Gu et al., 2022) | class-agnostic proposals of a Mask R-CNN | region embeddings classified by text embeddings, and distilled toward CLIP's embeddings of the cropped proposals | base-class boxes plus a CLIP or ALIGN teacher |
| OWL-ViT (Minderer et al., 2022) | every output token of a contrastively pretrained ViT | each token's embedding is compared with separately encoded queries; no fusion | image–text pretraining, then detection data |
| GLIP (Li et al., 2022) | a dense one-stage detector | region–word alignment scores, with cross-attention between the encoders | 27 million grounding pairs, mostly pseudo-labeled web data |
| Grounding DINO (Liu et al., 2024) | 900 queries of a DETR-style detector | fusion in the neck, in query selection and in the decoder | detection, grounding and caption data |
| Detic (Zhou et al., 2022) | a two-stage detector | text-embedding classifier also trained on image-level labels | detection data plus ImageNet-21K's 21,000 classes |
ViLD (Gu et al., 2022) starts from an observation: CLIP applied to cropped proposals already beats supervised detectors on LVIS's rare classes, but running CLIP on every crop is slow. So it trains a Mask R-CNN whose region embeddings are classified by CLIP text embeddings of the base classes (ViLD-text) and, at the same time, pulled toward CLIP's image embeddings of the cropped proposals (ViLD-image), a form of knowledge distillation:
OWL-ViT (Minderer et al., 2022) needs no proposals. It removes the final token pooling of a contrastively pretrained ViT and attaches to every output token a small MLP that predicts a box and a linear projection that gives the token's embedding, so a model with 576 tokens can output 576 objects (no LVIS image has more than 294). Image and queries are never fused, so one image pass serves thousands of queries, and the embedding of an example image can replace a text query for one-shot, image-conditioned detection. Fine-tuned with DETR's bipartite matching and a sigmoid focal loss, it reached 31.2 AP on LVIS's rare classes, with their names removed from all detection training data.
GLIP (Li et al., 2022) treats detection as a special case of phrase grounding. The class list becomes a prompt, "person. bicycle. car. … toothbrush.", and the classification logits become alignment scores between region features and the prompt's token features , while cross-attention between the two encoders in their last layers lets each condition the other. Grounding data can be produced at scale: a teacher GLIP pseudo-labeled 24 million web image–text pairs, for 27 million grounding pairs in all, and the largest GLIP reached 49.8 AP on COCO and 26.9 on LVIS in the paper's zero-shot setting, without fine-tuning on either. The fusion has a price: every new prompt means recomputing the fused layers, and GLIP caps a prompt at 256 tokens, so LVIS's categories were queried in chunks of 40.
Grounding DINO (Liu et al., 2024) fuses at three stages of a DETR-style detector: a feature enhancer that cross-attends image and text features, a language-guided selection of 900 decoder queries from the image features most similar to the text, and a cross-modality decoder; attention masks keep unrelated class names in one prompt from mixing. It reached 52.5 AP on COCO without COCO's training images. Detic (Zhou et al., 2022) adds names from image-level labels: each ImageNet-21K image's label trains the classifier on its largest proposal, which raised novel-class mAP on open-vocabulary LVIS by 8.3 points and gave one detector a vocabulary of more than 20,000 classes.
Grounding DINO reports 52.5 AP "zero-shot" on COCO. What does zero-shot mean in that claim?
- The model had never seen any of COCO's 80 categories during training
- No image of COCO's training split was used, although the detection and grounding data it was trained on name many of the same everyday objects
- The model was trained without any box annotations
- COCO's class names were replaced by new words before testing
Show the answer
B. No image of COCO's training split was used, although the detection and grounding data it was trained on name many of the same everyday objects
The paper defines zero-shot as not using the training split of the test dataset. "Person", "car" and "dog" appear throughout its training data, so the number measures transfer to a new dataset, not recognition of never-seen classes; LVIS's held-out rare categories come closer to that. Comparing "zero-shot" numbers across papers means checking what each one excluded.
One click, several answers
Segment Anything (SAM; Kirillov et al., 2023) defines segmentation as a promptable task. The input is an image plus a prompt, which may be foreground and background points, a box, a rough mask or, in an experiment, free text; the output must be a valid mask, one that is reasonable for at least one of the objects the prompt could mean. A single click on a person's shirt could mean the shirt, the person, or a pocket. What should a model trained on such prompts predict? Write each mask as a vector in , one entry per pixel.
(a) Expand around the mean ; the cross term vanishes because , so the first term is the only one that depends on :
For cross-entropy, pixel contributes , because . Setting the derivative to zero gives again: both losses are minimized by the marginal probability of each pixel.
(b) Each target is charged to its nearest output, so the loss is a sum over the cells . Holding the cells fixed, (a) applied inside each cell shows that moving to the cell's conditional mean cannot raise the loss, and strictly lowers it unless is already there; holding the outputs fixed, charging each target to its nearest output is optimal by definition. A minimum must satisfy both conditions, the fixed point of k-means applied to the distribution of targets:
A click lands on a person's shirt. Suppose annotators meant the shirt 40% of the time and the whole person 60% of the time. A single-output model trained with per-pixel cross-entropy converges, on the person's pixels outside the shirt, to what predicted probability, in percent?
Show the answer
60 %
Those pixels belong to the target only when the intent is "person", so the optimum is the marginal probability 0.6; the shirt's pixels converge to 1. The output is a calibrated average, not a mask: thresholded at 0.5 it returns the person and the shirt is lost, and with the split reversed it would return only the shirt. One output cannot represent both answers.
SAM applies (b), the minimum-over-outputs loss of multiple choice learning (Guzman-Rivera, Batra & Kohli, 2012). It predicts masks, because nested interpretations are rarely deeper than whole, part and subpart, and back-propagates only the lowest of the three losses, so each output is free to specialize. A small extra head predicts each mask's IoU with the object it covers, which ranks the outputs at test time without any ground truth. With several prompts, ambiguity mostly disappears, so a fourth output, never returned for a single prompt, supplies the one mask returned when more than one prompt is given.
The model and its data engine
SAM splits the work by cost. A heavy image encoder, a MAE-pretrained ViT adapted to high resolution, runs once per image on a input and outputs a embedding with 256 channels. A prompt encoder turns points and boxes into positional encodings plus a learned embedding for each prompt type (free text, experimentally, into a CLIP text embedding), and embeds a mask prompt with convolutions added to the image embedding. A light mask decoder, two transformer blocks with self-attention among the prompt tokens and cross-attention in both directions between those tokens and the image embedding, upsamples the embedding and maps each output token through an MLP to a dynamic linear classifier, whose dot product with the feature at every location gives the mask.
Given the image embedding, the prompt encoder and decoder answer in about 50 ms on a CPU in a web browser, fast enough for interactive clicking. Masks are trained with a focal loss and a dice loss in a 20:1 ratio, the IoU head with a squared error, in simulated interactive sessions of 11 rounds of prompts per mask.
The masks to train on did not exist, so the model helped to make them, in three stages:
- Assisted-manual. Annotators labeled masks by clicking foreground and background points in a tool powered by SAM and refined them with brush and eraser, and the model was retrained on the new masks as they accumulated: 4.3 million masks on 120,000 images.
- Semi-automatic. SAM pre-filled the confident masks and annotators added the objects it had missed: 5.9 million more masks on 180,000 images.
- Fully automatic. SAM was prompted with a grid of points; for each point the ambiguity-aware model returned its candidate masks, and only confident ones (high predicted IoU) and stable ones (thresholding the probability map at and gives nearly the same mask) were kept, with NMS removing duplicates.
Run on 11 million licensed images with faces and license plates blurred, the last stage produced SA-1B: 1.1 billion masks, 99.1% of them generated automatically, 400 times as many masks as any earlier segmentation dataset. To check quality, professional annotators corrected the automatic masks of 500 images: 94% of the corrected masks had IoU above 0.9 with the originals, and 97% above 0.75, where earlier studies put agreement between human annotators at 85–91% IoU.
Kirillov et al. evaluated zero-shot transfer: datasets and tasks not seen in training, solved by prompting. From one point at the center of each object, on 23 diverse segmentation datasets, SAM's most confident mask beat the strongest interactive segmenter, RITM, on 16; picking the best of its three masks by comparison with the ground truth, an "oracle" that measures ambiguity rather than skill, beat it on all 23, and human raters scored SAM's masks substantially higher. Prompted with a grid of points SAM produced edge maps and object proposals, and prompted with a detector's boxes it performed instance segmentation, none of which it was trained for; text-to-mask was a proof of concept.
Video, pipelines and limits
SAM 2 (Ravi et al., 2025) extends the task to promptable visual segmentation: prompts may come on any frame of a video, and the output is a masklet, the object's mask in every frame. The model is streaming. A hierarchical, MAE-pretrained image encoder (Hiera) embeds each frame once, as it arrives. Before decoding, memory attention, a stack of transformer blocks with self-attention and cross-attention, conditions the current frame on a memory bank: spatial memories of up to recent frames and up to prompted frames, each computed from that frame's predicted mask and features, plus object pointers, compact vectors taken from the decoder's output tokens. Only the recent frames' memories carry temporal position encodings, so the model can represent short-term motion. A new head predicts whether the object is visible at all, since it may be occluded, and the decoder, multiple masks for ambiguity included, follows SAM's.
With SAM 2 in the annotation loop, labeling took about 8.4 times less time per frame than annotating every frame with SAM, and the data engine produced SA-V: 642.6 thousand masklets (35.5 million masks) in 50.9 thousand videos, 53 times as many masks as any earlier video segmentation dataset. SAM 2 needed about 3 times fewer interactions than earlier methods in interactive video segmentation, and on images it was more accurate than SAM and 6 times faster.
Neither model names what it segments: a mask carries no class. Pipelines supply the names. Grounded SAM (Ren et al., 2024) feeds Grounding DINO's boxes for a text query to SAM as prompts and obtains masks for arbitrary text, reaching 48.7 mean AP on the SegInW benchmark (with Grounding DINO-Base and SAM-Huge), but a pipeline inherits the detector's misses and the segmenter's errors, which compound. Open-vocabulary segmentation is also learned directly: LSeg aligns per-pixel embeddings with CLIP text embeddings of class names (Li et al., 2022), MaskCLIP extracts dense predictions from a frozen CLIP with minimal changes and no annotations (Zhou, Loy & Dai, 2022), and OpenSeg first proposes masks, then aligns the words of captions with them (Ghiasi et al., 2022).
SAM's authors list its limits: it can miss fine structures, sometimes hallucinates small disconnected components, draws boundaries less crisply than methods that zoom in, and with its heavy encoder is not real-time as a whole; dedicated interactive tools beat it when given many clicks. Domain shift matters too. On 19 medical imaging datasets, Mazurowski et al. (2023) found SAM's IoU from a single prompt to range from 0.11 for spine MRI to 0.87 for hip X-rays, better with box prompts than with points, and improving only slightly with more points while other interactive methods overtook it.
Key takeaways
- Open-vocabulary detection replaces a learned classifier by text embeddings, with logits , so the vocabulary is chosen at test time; it is measured by holding classes out (LVIS's 337 rare of 1,203, reported as AP), and every "zero-shot" claim must say what was excluded.
- ViLD distills CLIP's embeddings of cropped proposals into a detector; OWL-ViT gives every ViT token a box and an embedding with no fusion, so it can answer thousands of queries; GLIP and Grounding DINO fuse image and text, gaining accuracy at the cost of re-encoding for every prompt; Detic learns names from image-level labels.
- One output trained on ambiguous prompts converges to the pixelwise average of the valid masks; with several outputs and a minimum-over-outputs loss, outputs specialize to a centroidal Voronoi tessellation. SAM predicts three masks, trains only the best, and ranks them with a predicted IoU.
- SAM runs a heavy MAE-pretrained ViT once per image and answers each prompt with a light prompt encoder and two-block decoder in about 50 ms on a CPU; its three-stage data engine produced SA-1B, 1.1 billion masks on 11 million images, 99.1% of them automatic.
- SAM 2 adds streaming memory, object pointers and a visibility head for video (SA-V: 642.6 thousand masklets). Masks carry no semantics, so pipelines such as Grounded SAM add names and compound errors; fine structures and domain shift (single-prompt IoU from 0.11 to 0.87 across medical datasets) remain hard.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
An open-vocabulary detector scores each region against the text queries with a softmax. You add the query "kitten" to a list that already contains "cat". What happens to the "cat" probability of regions that show cats?
- Nothing: each query's score depends only on its own text embedding
- It rises, because more animal classes give the model more context
- It falls, because the softmax now splits the probability between two near-synonyms; with independent sigmoid scores it would not change
- It becomes exactly zero, because a region can have only one label
Show the answer
C. It falls, because the softmax now splits the probability between two near-synonyms; with independent sigmoid scores it would not change
The softmax denominator sums over every query, so a new query can only lower the others' probabilities, and a near-synonym with a similar embedding takes a large share. OWL-ViT scores each query with its own sigmoid because its training labels overlap (one object can carry several names), and with independent scores a query's probability no longer depends on what else is in the list.
Why does ViLD, besides classifying regions with text embeddings, also distill CLIP's image embeddings of cropped proposals into its region embeddings?
- The text-embedding classifier is trained only on base-class labels, while proposals also contain novel objects; matching CLIP's embeddings of those crops transfers what those embeddings encode about them
- Distillation makes the region proposals more accurate
- CLIP's image embeddings replace the need for any box annotations
- It lets the detector run CLIP on every crop at test time
Show the answer
A. The text-embedding classifier is trained only on base-class labels, while proposals also contain novel objects; matching CLIP's embeddings of those crops transfers what those embeddings encode about them
ViLD-text learns only from base classes. ViLD-image runs on proposals regardless of their labels, including regions with rare objects, and pulls their embeddings toward CLIP's, so at test time the novel classes' text embeddings find matching regions. CLIP is used only offline, during training.
For an ambiguous single-point prompt, SAM computes the loss of each of its three masks but back-propagates only the lowest. Why?
- To save computation during training
- Because the lowest-loss mask is always the whole object
- So that each output can specialize on one interpretation; training all three on every target would pull each of them toward the same average mask
- So that the IoU head is no longer needed
Show the answer
C. So that each output can specialize on one interpretation; training all three on every target would pull each of them toward the same average mask
Under a summed loss every output would minimize the same expected error and converge to the pixelwise average of the valid masks. The minimum lets each output win the targets nearest to it and become their average, a centroidal Voronoi condition; with three outputs and up to three nested interpretations, each can learn one.
What lets SAM 2 keep segmenting an object after it has been occluded for several frames?
- It runs SAM independently on every frame with the original click
- Memory attention over stored memories of recent and prompted frames and object pointers, with a head that predicts whether the object is visible
- It estimates optical flow between frames and warps the previous mask forward
- It re-encodes all past frames with the image encoder at every new frame
Show the answer
B. Memory attention over stored memories of recent and prompted frames and object pointers, with a head that predicts whether the object is visible
Each frame is encoded once; its predicted mask and features become a memory in a bank of recent and prompted frames. The current frame cross-attends to these memories and to object pointers, so the object can be recovered when it reappears, and the visibility head lets the model output "no object" while it is hidden.
Further reading
- X. Gu, T.-Y. Lin, W. Kuo & Y. Cui, "Open-vocabulary object detection via vision and language knowledge distillation," ICLR (2022).
- L. H. Li et al., "Grounded language-image pre-training," CVPR (2022).
- A. Kirillov et al., "Segment anything," ICCV (2023).
- N. Ravi et al., "SAM 2: Segment anything in images and videos," ICLR (2025).
- C. Rupprecht, I. Laina, R. DiPietro, M. Baust, F. Tombari, N. Navab & G. D. Hager, "Learning in an uncertain world: Representing ambiguity through multiple hypotheses," ICCV (2017).