Manuscript Offprint
arXiv:2610.30623Refining Open-Vocabulary Semantic Segmentation via Regional Semantics and Visual Prototypes
ABSTRACT
Contrastive Language-Image Pre-training (CLIP) has shown superior performance in the image-level open-vocabulary classification task, benefiting from its powerful alignment of visual features and text embeddings. However, dense prediction tasks require models to perform pixel-level predictions, necessitating modifications to CLIP for region-text alignment. In this paper, we adjust the attention layers within the vanilla visual encoder of CLIP. With a novel attention calculation method for selective attention features, the model retains more regional semantic information. To further mitigate the negative impact of the modality gap, we introduce additional visual prototypes to refine the original predictor solely based on text embeddings. Specifically, patch features with confident predictions are selected to form an additional auxiliary memory-based classifier for more accurate prediction. We further integrate an optimizable feature extractor with an exponential moving average updating strategy to enhance prediction quality. Extensive experiments on 5 semantic segmentation datasets demonstrate the effectiveness of our method.
Index Terms— Semantic segmentation, Open-vocabulary, Contrastive language-image pre-training
1. INTRODUCTION
Semantic segmentation [1, 2] aims to classify an image at the pixel level, applying segmentation masks to separate diverse objects in the input. Conventional semantic segmentation methods follow a supervised paradigm, relying on manually labeled category annotations. To address the limitations of predefined categories, the Open-Vocabulary Semantic Segmentation (OVSS) task has been proposed and is receiving widespread attention. OVSS aims to effectively handle entirely new categories during inference, which may not have appeared during training. Recently, visual language models [3, 4] have shown remarkable generalization performance in image-level classification tasks [5, 6]. Inspired by this, some existing OVSS methods explore the potential of Contrastive Language-Image Pre-training (CLIP) [3] in pixel-level classification tasks. Most of them [4, 7, 8] follow a semi-supervised paradigm, utilizing both image-text pairs and additional dense annotations. Typically, these methods train a dense predictor with segmentation masks and expand target categories using image-text pairs [9, 10]. Furthermore, recent works improve feature extraction with additional image-text pairs [11], clustering features [12, 13], modifying structures [14, 15], aiming to convert image-level visual-text alignment to pixel-level visual-text alignment. MaskCLIP [14] revisits the global pooling layer of the visual encoder in the CLIP model, arguing that its value features already encompass rich pixel-level semantic information. Consequently, it directly calculates the similarity between the value features of the last attention module and the text embeddings to obtain accurate segmentation masks. However, the segmentation masks generated by MaskCLIP still exhibit noise. Recent work [16] suggests that while using the final value projection for prediction, the key and query projection in the attention module may concatenate features that do not belong to the same semantic category, thereby diminishing the correlation between pixels in neighboring regions. Additionally, existing methods remain constrained by the inherent vision-text modality gap of the CLIP.
To address the challenging OVSS task, we propose an annotation-free method to obtain high-quality segmentation masks in this work. We begin by introducing a regional semantic preservation module to refine pixel-level visual features. In this module, we modify the attention layer of the original CLIP image encoder, selectively reusing features that contain rich pixel-level semantic information. We design a novel attention calculation method for these features, enhancing regional semantic coherence by calculating the similarity of adjacent pixel-level features. To preserve local information and maintain the integrity of feature extraction, we modify only the final attention layer in pre-trained CLIP.
To mitigate the vision-language modality gap in CLIP, we further leverage additional visual prototypes of the entire unlabeled set to refine the dense predictions. For each semantic category, we select representative pixel-level features to form a visual feature memory module. Serving as an auxiliary dense predictor, the memory module computes the similarity of its vision embedding with the visual feature of the input image. The dense predictions from the auxiliary predictor are combined with the outcomes by text embeddings to construct the final segmentation results. The core idea of this design is to use the intra-domain similarity of the vision embedding and the input image to alleviate the vision-language modality gap inherent in CLIP. Additionally, we incorporate an additional feature extractor specifically tailored for semantic segmentation, optimizing it to enhance prediction performance further. The optimization is entirely supervised using model-generated masks of unlabeled samples, without relying on any annotated information during the process. To improve generalization and stability, we adopt an Exponential Moving Average (EMA) strategy to maintain a smoothly updated version of the feature extractor.
In summary, our contributions are as follows:
Xiao-Yu Zhang is the corresponding author (zhangxiaoyu@iie.ac.cn).

Fig. 1: The diagram of the Regional Semantic Preservation Module. We discard Wq and Wk, using only the value feature output by Wv for self-attention calculation. This mechanism yields dense features that better capture regional semantic information.
• We propose a novel attention modification method based on vanilla CLIP to preserve regional semantics. We intuitively modify the final attention layer of CLIP's image encoder, devising a specific attention calculation method to obtain pixel-level visual features with greater local semantic consistency.
• We introduce a prediction enhancement strategy with visual prototypes. A visual feature memory module is designed to select representative visual prototypes for each category. Serving as an auxiliary dense predictor, this module mitigates the modality gap of text embeddings and images.
• We achieve state-of-the-art annotation-free semantic segmentation performance compared to existing methods.
2.1. Preliminaries
Contrastive Language-Image Pre-Training (CLIP) model achieves cross-modal understanding by jointly training a text encoder T and an image encoder I with abundant image-text pairs. For a K-class classification task, each class has a text description , such as the category name with a unified prompt prefix. Consider a test image , CLIP model first utilizes the image encoder to extract its visual feature . To aggregate the sub-features of each spatial position in image feature extraction, image encoder contains an attention-based pooling layer. It treats the averaged sub-feature as the query feature and all sub-features as key-value features, the self-attention mechanism is computed as,
where the and are key and value features extracted by the linear embedding layer at each spatial position , and is the average of all query features. The text description is fed into the text encoder to obtain textual feature . The final prediction probability is calculated as follows:
where cos represents the cosine similarity and is the temperature.
MaskCLIP presents the hypothesis that the computed at each spatial position already captures rich local semantic responses, well aligned with the text embeddings of the CLIP. Therefore, MaskCLIP directly inputs into the text-embedding based predictor, discarding the keys and queries, and achieves amazing performance improvements on annotation-free segmentation tasks.
2.2. Regional Semantic Preservation Module
Although contains abundant per-pixel semantic information, it overlooks the semantic correlation among neighboring regions. Additionally, the q-k mapping in the self-attention module encourages the model to focus on the global information of images, which may not be suitable for dense prediction tasks. To address this issue, we propose the Regional Semantic Preservation Module, aimed at guiding the model to focus more on regional semantic information. Specifically, as demonstrated in Figure 1, we introduce a novel self-attention calculation method to promote the consistency of visual features in adjacent spatial regions. We modify the last attention layer in the pre-trained CLIP and employ a v-v mapping to replace the original q-k mapping, which is defined as:
This intuitive modification emphasizes the similarity of adjacent pixel-level features and enhances the clustering of nearby features, aggregating semantically related areas while mitigating attention to semantically irrelevant regions. We only revise the attention layer within the final self-attention block, aiming to enhance the prediction performance while preserving feature extraction functionality with minimal adjustments.
2.3. Prediction Enhancement with Visual Prototypes
In this section, we present a Prediction Enhancement strategy with Visual Prototypes, aiming to refine the classification outputs from text embeddings. As shown in Figure 2, we employ a feature cache module to store the most representative visual features for each semantic category. The vision embeddings in the memory module are employed as an additional predictor, to align features within the visual modality and, to some extent, alleviate the modality gap between text and vision embeddings. The predicted results of vision embeddings and text embeddings are combined in a residual way, which reconciles the final segmentation results while retaining the rich semantic knowledge in the text embeddings of CLIP.
Specifically, for each image in the target dataset , we first input them into MaskCLIP for preliminary dense prediction. we extract pixel-level visual features for each image using the modified image encoder of MaskCLIP in Section 2.2:
Meanwhile, we use and to denote text embeddings for each semantic category and the text-embedding based predictor, respectively. For an image , the category prediction probability at each spatial location can be obtained by Calculating the similarity between its features and text embeddings, which can be abbreviated as:

Fig. 2: The pipeline of Visual Feature Memory Module. Given the inputs, we employ the regional semantic preservation module in Section 2.2 to extract the dense features. Then, the text embeddings of CLIP output the class prediction and the corresponding probability confidence. The feature cache is used to select the visual features with Top-K confidence, which are averaged and set as vision embeddings.

Fig. 3: Overview of our method. The input image is encoded by the regional semantic preservation module in Section 2.2, followed by the refined predictor in Section 2.3 for semantic segmentation.
We select the visual features corresponding to pixels with top-K category prediction confidence for each target category . The visual feature prototype of each target category is obtained by averaging the top-K visual features as:
We normalize the visual feature prototype into the same form as the text embeddings, which is named pixel embedding , thereby obtaining the vision-embedding based predictor . The final semantic result is then calculated as:
where is the residual ratio. In this manner, the refined predictor encompasses both prediction outcomes of the visual modality and the original text-image alignment results.
2.4. Self-training
To fully harness the capabilities of the segmentation network, we replace the vision encoder of CLIP with an optimized auxiliary feature extractor customized for semantic segmentation. We utilize the segmentation outcomes generated by the refined predictor in Section 2.3 as pseudo-labels for optimization. To express concisely, the revised predictor is ensembled by and , which is expressed as . We replace the original classifiers with , to produce open-vocabulary semantic segmentation. Additionally, we employ the Exponential Moving Average (EMA) in the inference stage to smooth the learned parameters of the target feature extractor, . We follow the official settings ( ) for model inference.
3. EXPERIMENTS
3.1. Implementation Details
We use 5 standard segmentation benchmarks to evaluate our method, namely ADE20K [17], Cityscapes [18], COCO Stuff164k [19], PASCAL Context [20], and VOC12AUG [21]. This work considers two publicly available visual backbones, namely CLIP-ResNet-50 [3] and CLIP-ViT-B/16 [3] models. For CLIP-ResNet-50, the modification involves rewriting the final global pooling layer, replacing both q-projection and k-projection with v-projection. For CLIP-ViT-B/16, we directly reuse the output v of the last attention block to conduct additional self-attention calculations. In the training-free prediction, the refined predictor proposed in Section 2.4 directly outputs segmentation results. The settings of top-K & λ are shown in Table 1. We use 85 predefined prompt templates to encode corresponding text embeddings and average them for each category as in ViLD [22]. Following MaskCLIP+, we employ DeepLabv2-ResNet101 [23] which is initialized with the ImageNet [24] pretrained weights as the target model. Our method is implemented
Table 1: Hyper-parameter settings in our method across different datasets. denotes hyper-parameters in the distillation process.
| Datasets | ADE | City | COCO | PC | VOC |
|---|---|---|---|---|---|
| Top-K | 512 | 128 | 4,096 | 1,024 | 128 |
| λ | 0.5 | 0.05 | 0.5 | 0.5 | 0.5 |
| Training Iterations | 8,000 | 4,000 | 8,000 | 4,000 | 2,000 |
Table 2: Quantitative results (mIoU, %) comparison on 5 semantic segmentation benchmarks. MaskCLIP means their baseline without refinement. We highlight the best and the second-best results.
| Method | ADE | City | COCO | PC | VOC | Avg. |
|---|---|---|---|---|---|---|
| CLIP [3] | 3.1 | 6.5 | 5.7 | 11.1 | 49.4 | 14.1 |
| MaskCLIP+ [14] | 10.8 | 21.6 | 14.7 | 23.3 | 53.7 | 23.7 |
| MaskCLIP+ [14] | 11.9 | 24.9 | 16.7 | 26.4 | 74.9 | 30.3 |
| GroupViT [13] | 10.4 | 18.5 | 15.3 | 23.4 | 79.7 | 30.7 |
| ReCLIP [25] | 14.3 | 19.9 | 20.2 | 33.7 | 75.8 | 32.8 |
| ReCo [15] | 11.2 | 21.6 | 14.8 | 22.3 | 57.7 | 23.5 |
| TCL [11] | 14.9 | 23.5 | 19.6 | 30.3 | 77.5 | 33.9 |
| CLIP Surgery [16] | 12.9 | 31.4 | 21.9 | - | - | - |
| CoCu [26] | 11.1 | 15.0 | 13.6 | - | - | - |
| GEM [27] | 15.9 | - | - | 32.6 | - | - |
| Ours | 17.2 (+1.3) | 32.5 (+1.1) | 20.3 | 33.7 (+1.1) | 75.7 | 35.9 (+2.0) |
Table 3: Quantitative results (mIoU, %) under CLIP-ResNet-50. Ours with ◇ symbol denotes the training-free setting.
| Method | ADE | City | COCO | PC | VOC | Avg. |
|---|---|---|---|---|---|---|
| MaskCLIP | 8.3 | 18.8 | 10.2 | 18.5 | 41.5 | 19.5 |
| Ours | 11.5 | 22.1 | 15.0 | 24.4 | 59.0 | 26.4 |
| MaskCLIP+ | 10.7 | 23.4 | 13.6 | 24.2 | 57.3 | 25.8 |
| Ours | 13.0 | 26.9 | 16.4 | 28.0 | 70.2 | 30.9 |

Fig. 4: Qualitative results on all the 5 datasets. Each 3 closely arranged images form a group, in which the upper left corner, lower left corner, and right image are respectively the input image, ground truth, and the visualization result of the proposed method.
based on the MMSegmentation codebase and executed on 4 Nvidia 4090 GPUs.
3.2. Main Results
Comparison to Open-vocabulary semantic segmentation Methods. In Table 2, we present the comparison results (mIoU, %) of our method with other existing open-vocabulary semantic segmentation models, including MaskCLIP [14], GroupViT [13], ReCo [15], TCL [11], CLIP Surgery [16], and GEM [27]. For fairness in comparison, we do not include the additional PAMR post-processing layer in any of the methods. As demonstrated in In Table 2, our method achieves state-of-the-art performance on ADE20K(17.2%), Cityscapes(32.5%), and PASCAL Context(33.7%). Besides, the average performance of ours reaches 35.9%, which is also the highest compared to other methods.
Table 4: Ablation results (mIoU, %) of each component in our method. A., V., and E. denote the refined self-attention in Section 2.2, vision embeddings saved by the visual feature memory module in Section 2.3, and the optimization strategy in Section 2.4, respectively.
| Self-train | Method | ADE | City | COCO | PC | VOC | Avg. |
|---|---|---|---|---|---|---|---|
| ✕ | MaskCLIP | 9.5 | 19.8 | 12.5 | 21.7 | 49.5 | 22.6 |
| + A. | 10.0 | 20.6 | 13.2 | 22.7 | 51.4 | 23.6 | |
| + A. + V. | 12.6 | 20.7 | 15.3 | 25.1 | 56.2 | 26.0 | |
| ✓ | MaskCLIP+ | 11.9 | 24.9 | 16.7 | 26.4 | 74.9 | 31.0 |
| + A. | 15.2 | 32.3 | 19.1 | 32.4 | 75.3 | 34.9 | |
| + A. + V. | 17.1 | 32.1 | 20.2 | 32.6 | 75.6 | 35.5 | |
| + A. + V. + E. | 17.2 | 32.5 | 20.3 | 33.7 | 75.7 | 35.9 |
Experiments on Other Visual Backbone. Our approach is also applicable to CLIP-ResNet-50. In Table 3, we present the quantitative evaluation across 5 datasets. Both the training-free prediction and self-training setting are considered in the evaluation. The results demonstrate that our method can still enhance dense prediction performance on CLIP-ResNet-50 to a certain extent.
Qualitative Results. In Figure 4, we showcase the qualitative outcomes of our method across 5 diverse datasets. Each column corresponds to images sourced from the same dataset. In each row of Figure 4, for each dataset, 3 images form a combination. Among them, the top-left image represents the input image, the bottom-left image depicts the ground truth, and the image on the right showcases the dense prediction results produced by our method. The experimental results demonstrate our method's ability to accurately delineate object boundaries, ensuring precise localization, and maintaining a nuanced understanding of local context.
Ablation Study We analyze the effectiveness of each component in the proposed method. Through a series of ablation experiments conducted across all 5 datasets utilizing the CLIP-ViT-B/16 backbone, we meticulously assess the impact of various elements on overall performance. In Table 4, we present the outcomes obtained from both training-free prediction and self-training. The experimental results indicate that our proposed components yield significant improvements across all datasets.
4. CONCLUSION
In this work, we focus on open-vocabulary semantic segmentation with an annotation-free setting. In this task, dense features generated by CLIP's visual encoder are utilized to align with text embeddings for dense prediction. We suggest that the inherent attention mechanism of the image encoder in CLIP is not entirely suitable for semantic segmentation, as the visual features tend to focus on the global information of the image rather than pixel-level semantics. We propose a novel attention computation approach that encourages the image encoder to preserve semantic consistency among features from adjacent regions to a greater extent. Additionally, we introduce a feature memory module that stores visual feature prototypes as an additional predictor, collaborating with text embeddings for dense prediction. Our approach achieves state-of-the-art performance across multiple benchmarks, demonstrating the superiority of the proposed components.
5. ACKNOWLEDGMENTS
This work was supported by the National Natural Science Foundation of China (NSFC) (Grant 62376265). It was also supported by the National Natural Science Foundation of China under Grants (62276256, U2441251).
6. ETHICAL STANDARDS STATEMENT
This is a numerical simulation study for which no ethical approval was required.
7. REFERENCES
[1] Jonathan Long, Evan Shelhamer, and Trevor Darrell, “Fully convolutional networks for semantic segmentation,” in Proc. CVPR, 2015, pp. 3431–3440.
[2] Yuxi Wang, Jian Liang, and Zhaoxiang Zhang, “A curriculum-style self-training approach for source-free semantic segmentation,” IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 46, no. 12, pp. 9890–9907, 2024.
[3] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al., “Learning transferable visual models from natural language supervision,” in Proc. ICML, 2021, pp. 8748–8763.
[4] Chao Jia, Yinfei Yang, Ye Xia, Yi-Ting Chen, Zarana Parekh, Hieu Pham, Quoc Le, Yun-Hsuan Sung, Zhen Li, and Tom Duerig, “Scaling up visual and vision-language representation learning with noisy text supervision,” in Proc. ICML, 2021, pp. 4904–4916.
[5] Jian Liang, Lijun Sheng, Zhengbo Wang, Ran He, and Tieniu Tan, “Realistic unsupervised clip fine-tuning with universal entropy optimization,” in Proc. ICML, 2024, pp. 29667–29681.
[6] Hao Dong, Lijun Sheng, Jian Liang, Ran He, Eleni Chatzi, and Olga Fink, “Adapting vision-language models without labels: A comprehensive survey,” International Journal of Computer Vision, vol. 134, no. 8, pp. 389, 2026.
[7] Fei Zhang, Tianfei Zhou, Boyang Li, Hao He, Chaofan Ma, Tianjiao Zhang, Jiangchao Yao, Ya Zhang, and Yanfeng Wang, “Uncovering prototypical knowledge for weakly open-vocabulary semantic segmentation,” in Proc. NeurIPS, 2023, vol. 36.
[8] Jie Qin, Jie Wu, Pengxiang Yan, Ming Li, Ren Yuxi, Xuefeng Xiao, Yitong Wang, Rui Wang, Shilei Wen, Xin Pan, et al., "Freeseg: Unified, universal and open-vocabulary image segmentation," in Proc. CVPR, 2023, pp. 19446–19455.
[9] Golnaz Ghiasi, Xiuye Gu, Yin Cui, and Tsung-Yi Lin, “Scaling open-vocabulary image segmentation with image-level labels,” in Proc. ECCV. Springer, 2022, pp. 540–557.
[10] Feng Liang, Bichen Wu, Xiaoliang Dai, Kunpeng Li, Yinan Zhao, Hang Zhang, Peizhao Zhang, Peter Vajda, and Diana Marculescu, “Open-vocabulary semantic segmentation with mask-adapted clip,” in Proc. CVPR, 2023, pp. 7061–7070.
[11] Junbum Cha, Jonghwan Mun, and Byungseok Roh, “Learning to generate text-grounded mask for open-world semantic segmentation from only image-text pairs,” in Proc. CVPR, 2023, pp. 11165–11174.
[12] Quande Liu, Youpeng Wen, Jianhua Han, Chunjing Xu, Hang Xu, and Xiaodan Liang, “Open-world semantic segmentation via contrasting and clustering vision-language embedding,” in Proc. ECCV. Springer, 2022, pp. 275–292.
[13] Jiarui Xu, Shalini De Mello, Sifei Liu, Wonmin Byeon, Thomas Breuel, Jan Kautz, and Xiaolong Wang, “Groupvit: Semantic segmentation emerges from text supervision,” in Proc. CVPR, 2022, pp. 18134–18144.
[14] Chong Zhou, Chen Change Loy, and Bo Dai, “Extract free dense labels from clip,” in Proc. ECCV. Springer, 2022, pp. 696–712.
[15] Gyungin Shin, Weidi Xie, and Samuel Albanie, “Reco: Retrieve and co-segment for zero-shot transfer,” in Proc. NeurIPS, 2022, vol. 35, pp. 33754–33767.
[16] Yi Li, Hualiang Wang, Yiqun Duan, and Xiaomeng Li, “Clip surgery for better explainability with enhancement in open-vocabulary tasks,” arXiv preprint arXiv:2304.05653, 2023.
[17] Bolei Zhou, Hang Zhao, Xavier Puig, Tete Xiao, Sanja Fidler, Adela Barriuso, and Antonio Torralba, “Semantic understanding of scenes through the ade20k dataset,” International Journal of Computer Vision, vol. 127, pp. 302–321, 2019.
[18] Marius Cordts, Mohamed Omran, Sebastian Ramos, Timo Rehfeld, Markus Enzweiler, Rodrigo Benenson, Uwe Franke, Stefan Roth, and Bernt Schiele, “The cityscapes dataset for semantic urban scene understanding,” in Proc. CVPR, 2016, pp. 3213–3223.
[19] Holger Caesar, Jasper Uijlings, and Vittorio Ferrari, “Coco-stuff: Thing and stuff classes in context,” in Proc. CVPR, 2018, pp. 1209–1218.
[20] Roozbeh Mottaghi, Xianjie Chen, Xiaobai Liu, Nam-Gyu Cho, Seong-Whan Lee, Sanja Fidler, Raquel Urtasun, and Alan Yuille, “The role of context for object detection and semantic segmentation in the wild,” in Proc. CVPR, 2014, pp. 891–898.
[21] Mark Everingham, Luc Van Gool, Christopher KI Williams, John Winn, and Andrew Zisserman, “The pascal visual object classes (voc) challenge,” International Journal of Computer Vision, vol. 88, pp. 303–338, 2010.
[22] Xiuye Gu, Tsung-Yi Lin, Weicheng Kuo, and Yin Cui, “Open-vocabulary object detection via vision and language knowledge distillation,” in Proc. ICLR, 2021.
[23] Liang-Chieh Chen, Yukun Zhu, George Papandreou, Florian Schroff, and Hartwig Adam, “Encoder-decoder with atrous separable convolution for semantic image segmentation,” in Proc. ECCV, 2018, pp. 801–818.
[24] Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei, “Imagenet: A large-scale hierarchical image database,” in Proc. CVPR, 2009, pp. 248–255.
[25] Jingyun Wang and Guoliang Kang, “Learn to rectify the bias of clip for unsupervised semantic segmentation,” in Proc. CVPR, 2024, pp. 4102–4112.
[26] Yun Xing, Jian Kang, Aoran Xiao, Jiahao Nie, Ling Shao, and Shijian Lu, “Rewrite caption semantics: Bridging semantic gaps for language-supervised semantic segmentation,” in Proc. NeurIPS, 2024, vol. 36, pp. 68798–68809.
[27] Walid Bousselham, Felix Petersen, Vittorio Ferrari, and Hilde Kuehne, “Grounding everything: Emerging localization properties in vision-language transformers,” in Proc. CVPR, 2024, pp. 3828–3837.