Pay Attention to Your Neighbours: Training-Free Open-Vocabulary Semantic Segmentation

Sina Hajimiri, Ismail Ben Ayed, Jose Dolz

Introduction

Open-Vocabulary Semantic Segmentation (OVSS) aims to recognize and segment any visual concept described in natural language, moving beyond the "closed-set" limitations of traditional models. While Contrastive Language-Image Pre-training (CLIP) provides a robust foundation for zero-shot tasks, its global training objective often results in poor local feature alignment, hindering precise pixel-level segmentation. Existing solutions typically involve expensive fine-tuning or auxiliary models, which can compromise CLIP's inherent zero-shot flexibility.

The NACLIP Framework

NACLIP (Neighbour-Aware CLIP) addresses the localization challenges of CLIP through three surgical, training-free modifications to the Vision Transformer (ViT) architecture. These changes align the model's internal logic with the requirements of dense spatial grouping.

Spatial Consistency via Gaussian Kernels

Standard self-attention allows any patch to attend to any other, regardless of spatial distance. NACLIP introduces a Gaussian kernel to the self-attention mechanism, effectively prioritizing local neighborhoods. This ensures that nearby pixels, which are likely part of the same object, maintain consistent representations.

Key-Key Similarity

In contrast to standard Query-Key attention designed for retrieval, NACLIP utilizes Key-Key similarity. This shift focuses on the inherent visual characteristics of patches, facilitating the grouping of similar visual elements rather than searching for specific features. This is more suited for segmentation, where the goal is to cluster similar pixels together.

Figure 2: Conceptual overview of the NACLIP modifications to the attention mechanism, incorporating Gaussian weighting and Key-Key similarity compared to vanilla CLIP.

Architectural Simplification

The authors observed that the final layer of CLIP's visual encoder is heavily biased toward global classification tasks. By removing the feed-forward network (FFN) and skip connections in this final layer, NACLIP preserves dense spatial details that are otherwise obscured by classification-specific features.

Experimental Evaluation

NACLIP was evaluated across eight diverse benchmarks, including PASCAL VOC, ADE20K, and Cityscapes, to demonstrate its generalizability.

Quantitative Performance

NACLIP achieved state-of-the-art (SOTA) results among training-free methods on 7 out of 8 benchmarks. Notably, on PASCAL Context (PC59), it reached a mean Intersection over Union (mIoU) of 38.4%, surpassing the previous best method, SCLIP (36.1%). Furthermore, NACLIP demonstrates superior stability when scaling from ViT-B to ViT-L backbones; while SCLIP’s performance dropped by 12% on larger models, NACLIP remained robust with only a minor 4% change.

Qualitative Analysis

Visual comparisons highlight NACLIP's ability to produce coherent, noise-free segmentation masks. Unlike vanilla CLIP, which often generates fragmented or "speckled" attention maps, NACLIP's focus on local neighborhoods results in masks that closely align with ground truth boundaries.

Figure 3: Qualitative comparison of segmentation results. NACLIP (Ours) produces significantly cleaner and more accurate masks compared to vanilla CLIP and SCLIP across various categories like horses, buses, and sheep.

Conclusion and Future Work

NACLIP demonstrates that simple, training-free inductive biases—specifically locality and architectural pruning—can significantly unlock CLIP's potential for dense prediction tasks. While it sets a new bar for zero-shot segmentation, a gap remains between training-free approaches and fully supervised models. Future research may explore better integration of global tokens like [CLS] to further bridge this gap and refine the extraction of spatial information.

Summary updated

BibTeX
@inproceedings{hajimiri2025pay,
  author = {Sina Hajimiri and Ismail Ben Ayed and Jose Dolz},
  title = {{Pay Attention to Your Neighbours: Training-Free Open-Vocabulary Semantic Segmentation}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2025},
  doi = {10.1109/wacv61041.2025.00495},
}
Figure