NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Unveiling the Knowledge of CLIP for Training-Free Open-Vocabulary Semantic Segmentation

Yajie Liu, Guodong Wang, Jinjin Zhang, Qingjie Liu, Di Huang

Abstract

Open-Vocabulary Semantic Segmentation (OVSS) aims to segment arbitrary objects based on text prompts without category-specific training. While CLIP has become the foundation for training-free OVSS, its final-layer features often suffer from "semantic contamination," where dominant object signals bleed into surrounding regions. This paper introduces CLIPSeg, a training-free framework that leverages the superior spatial grouping capabilities of CLIP's middle layers and cleanses deep-layer patch semantics. By introducing Coherence Enhanced Residual Attention (CRA) and Deep Semantic Integration (DSI), CLIPSeg achieves state-of-the-art performance across nine benchmarks, outperforming existing methods by up to 7.8% mIoU.

Introduction

The ability to segment any object in an image using natural language prompts—Open-Vocabulary Semantic Segmentation (OVSS)—is a cornerstone of flexible computer vision systems. Contrastive Language-Image Pre-training (CLIP) models are the primary drivers of this field due to their vast zero-shot capabilities. However, CLIP was optimized for image-level classification. When repurposed for pixel-level tasks like segmentation, standard approaches typically extract features from the final layer.

The authors of this AAAI-25 paper argue that the final layer is not the optimal source for spatial information. Instead, they reveal that CLIP's internal knowledge follows a specific trajectory: spatial coherence peaks in the middle layers, while the final layers prioritize global semantic alignment at the cost of local structural integrity.

The Problem: Semantic Contamination

Existing training-free methods often struggle with blurry boundaries and "bleeding" effects. This is caused by semantic contamination. In the final layers of a Vision Transformer (ViT) like CLIP, self-attention mechanisms allow the most prominent object (e.g., a horse) to dominate the feature representations of all other patches (e.g., the grass or trees). While this helps image-level classification, it destroys the local distinctness required for accurate segmentation.

Visualization of semantic contamination in CLIP's final layer, where horse features (red) bleed into the tree region (blue).

Methodology: The CLIPSeg Framework

To address these issues, CLIPSeg introduces two key modules that modify the inference pipeline of a frozen CLIP model without requiring any training or fine-tuning.

The CLIPSeg framework: (Left) Architecture modifications for segmentation. (Right) Qualitative comparison showing how CLIPSeg produces cleaner attention maps and more precise patch semantics.

1. Coherence Enhanced Residual Attention (CRA)

The researchers discovered a "U-shaped" coherence curve: the ability of features to group similar parts of an object together is strongest in the middle layers (e.g., layer 9 of a 24-layer ViT-L). CRA identifies these optimal layers to construct attention maps ($Attn$). By using these coherent middle-layer features, the model ensures that attention is focused on well-defined object regions rather than the noisy, diffused maps produced by the final layers.

2. Deep Semantic Integration (DSI)

To refine the patch semantics ($V$), DSI looks at the deep layers but changes how they are processed. The authors found that the self-attention step in the final blocks is the primary source of contamination. DSI bypasses this step, regenerating dense outputs from deep layers to maintain "locally pure" features. These clean features are then integrated with the final layer's semantic information, producing a map that is both text-aligned and spatially precise.

Experimental Evaluation

The authors conducted extensive testing across nine major segmentation benchmarks, including Pascal VOC, Pascal Context, COCO-Stuff, ADE20k, and Cityscapes. They evaluated CLIPSeg using eight different CLIP backbones (OpenAI, OpenCLIP, MetaCLIP).

Key Results

  • Performance Gains: CLIPSeg achieved a significant 7.8% mIoU improvement over previous state-of-the-art methods like ClearCLIP when using a ViT-L backbone.
  • MetaCLIP Synergy: On the Meta-L-5B model, the improvement reached 8.9% mIoU compared to the GEM method.
  • Competitive with Supervised Models: Remarkably, this training-free approach outperformed several weakly-supervised methods that utilize additional training data. For instance, on the C459 benchmark, CLIPSeg reached 11.5% mIoU, surpassing the trained DeOP model (9.4%).

Discussion and Insights

The success of CLIPSeg highlights three critical insights into CLIP's internal mechanics:

  1. The Middle Layer Advantage: Spatial awareness is a transient property in CLIP that peaks well before the final output.
  2. Self-Attention as a Double-Edged Sword: While essential for global context, self-attention acts as a "diffuser" that can obscure local details in deep layers.
  3. Training-Free Potential: Significant performance leaps are still possible in zero-shot tasks simply by better understanding and "unveiling" the latent knowledge already present in large-scale pre-trained models.

Conclusion

CLIPSeg demonstrates that the "hidden" layers of CLIP contain the keys to high-fidelity semantic segmentation. By strategically extracting attention from middle layers and purifying semantic features from deep layers, the framework sets a new standard for training-free OVSS. This work paves the way for more efficient, zero-shot computer vision applications that do not require the heavy computational cost of fine-tuning.

Summary updated

BibTeX
@inproceedings{liu2025unveiling,
  author = {Yajie Liu and Guodong Wang and Jinjin Zhang and Qingjie Liu and Di Huang},
  title = {{Unveiling the Knowledge of CLIP for Training-Free Open-Vocabulary Semantic Segmentation}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i6.32602},
}
Figure