
clipseg (zero shot image classification)
Segmentation622 ops149.6M params
Frozen CLIP ViT-B/16 plus a tiny FiLM-conditioned transformer decoder that segments whatever a text or image prompt names.
Segmentation · 693 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
About this model's family
CLIPSeg is Timo Lüddecke and Alexander S. Ecker's prompt-driven segmenter: instead of a fixed set of object classes, it can generate image segmentations based on arbitrary prompts at test time, and a prompt can be either a text or an image. That flexibility lets one model, trained once, cover three segmentation tasks with distinct challenges: referring expression segmentation, zero-shot segmentation and one-shot segmentation. The authors also find the system adapts well to generalized queries involving affordances or properties.
The backbone is the visual transformer-based (ViT-B/16) CLIP model, extended with a small, parameter-efficient transformer decoder, and CLIP itself is not trained, but only used as a frozen feature extractor. The decoder is a simple, purely-transformer based decoder, which has U-Net-inspired skip connections to the CLIP encoder that allow the decoder to be compact (in terms of parameters). To tell the decoder what to segment, the authors modulate the decoder's input activation by a conditional vector using FiLM, a vector that comes either from the CLIP text-transformer embedding of a text query or from the CLIP visual transformer on a feature engineered prompt image. CLIP activations are read out at layers S = [3, 7, 9], so the decoder has only three layers, and with a projection dimension of D = 64 CLIPSeg has only 1,122,305 trainable parameters. Training was on PhraseCut+, an extended version of the PhraseCut dataset, after which the system generates a binary segmentation map for an image based on a free-text prompt or on an additional image expressing the query.
Both members here are the transformers port of the authors' rd64-refined weights, which the Hub card describes as the CLIPSeg model with reduce dimension 64, refined (using a more complex convolution), intended for zero-shot and one-shot image segmentation. The segmentation member returns per-pixel classification scores for each pixel at the 352 px the paper used throughout its experiments, while the second member is the bare CLIPSeg model whose outputs are the scaled dot product scores between image_embeds and text_embeds, the CLIP-style similarity without the decoder. The original CLIP is constrained to a fixed image size due to the learned positional embedding, so the authors interpolate those embeddings to allow other sizes, and for ViT-B/16 performance only decreases for images larger than 350 pixels. CLIPSeg was integrated into the HuggingFace Transformers library in November 2022, and the paper was accepted to CVPR 2022.
Key idea. A compact transformer decoder with U-Net-style skips into a frozen CLIP ViT-B/16, FiLM-conditioned on a text or image prompt, producing a binary mask for any query.
AI-written summary, checked automatically against its sources; not reviewed by a person. Corrections welcome.
@misc{lüddecke2022imagesegmentationusingtext,
title={Image Segmentation Using Text and Image Prompts},
author={Timo Lüddecke and Alexander S. Ecker},
year={2022},
eprint={2112.10003},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2112.10003},
}