GOPro: Generate and Optimize Prompts in CLIP using Self-Supervised Learning

Mainak Singha, Ankit Jha, Biplab Banerjee

Introduction

Vision-language models, most notably CLIP, have fundamentally changed the landscape of computer vision by enabling zero-shot recognition through natural language prompts. However, the effectiveness of these models is highly sensitive to prompt engineering. While manual prompting is labor-intensive and often sub-optimal, recent automated "learnable" prompting techniques like CoOp and CoCoOp have emerged. Despite their success, these methods frequently struggle with domain generalization—failing to maintain performance when faced with stylized, sketched, or otherwise out-of-distribution versions of training data.

GOPro (Generate and Optimize Prompts) addresses this by integrating self-supervised learning (SSL) directly into the prompt-learning pipeline. By disentangling visual content from style and enforcing a novel consistency loss across image augmentations, GOPro generates robust, domain-agnostic prompts that significantly outperform existing state-of-the-art methods.

Methodology

The GOPro framework introduces lightweight, learnable vision and text projectors while keeping the massive CLIP backbone frozen. This ensures computational efficiency while leveraging the powerful pre-trained representations of CLIP.

Disentangled Feature Extraction

Rather than relying solely on high-level semantic features, GOPro utilizes a Feature Rescaling Gap (FRG) layer. This layer extracts multi-scale content and global style information (represented by instance-wise mean and standard deviation) from the CLIP vision encoder. These disentangled features are then processed by a meta-network ($\rho$) to generate class-specific prompt token embeddings.

The GOPro architecture utilizes frozen CLIP encoders with learnable projectors and a multi-loss strategy to ensure semantic invariance.

Triple-Loss Objective

To ensure the learned prompts are invariant to domain shifts, GOPro employs a three-pronged optimization strategy:

  1. Visual Contrastive Loss ($L_{Con}$): Utilizes MoCo v3 augmentations to train the vision projector to recognize features regardless of geometric transformations.
  2. Image-Text Contrastive Loss ($L_{ce}$): The standard CLIP objective used to align visual embeddings with their corresponding textual descriptions.
  3. Prompt Consistency Loss ($L_{Sem}$): This is the core innovation of GOPro. It forces the model to produce nearly identical prompt embeddings for an original image and its various augmented versions (created via MoCo v3 and AugMix). By treating the original image's prompt as a "teacher" and the augmented versions as "students," the model learns a shared embedding space robust to photometric and geometric noise.

Experimental Results

The authors evaluated GOPro across 11 diverse image recognition datasets, ranging from generic objects (ImageNet) and fine-grained categories (OxfordPets, StanfordCars) to specialized domains like satellite imagery (EuroSAT) and textures (DTD). It was also tested on rigorous domain generalization benchmarks including ImageNet-Sketch and ImageNet-R.

Performance and Generalization

GOPro demonstrated a clear lead over previous prompting techniques. In base-to-new generalization tests across 11 datasets, GOPro achieved a harmonic mean (HM) of 80.62%, substantially outperforming the SSL-based SLIP (71.96%) and CoCoOp (75.83%). Ablation studies confirmed that the $L_{Sem}$ consistency loss is vital, as its removal led to a performance drop of over 2%.

Qualitative Analysis

t-SNE visualizations provide further evidence of GOPro's efficacy. Compared to competitors, GOPro produces significantly tighter and more distinct class clusters, even when processing noisy or augmented data. This indicates a higher degree of class discriminativeness and robustness to domain variance.

t-SNE visualizations show that GOPro achieves significantly better class discriminativeness and tighter clustering than SLIP or CoCoOp.

Conclusion and Future Work

GOPro successfully bridges the gap between self-supervised learning and prompt optimization. By explicitly separating style from content and enforcing semantic consistency, it creates prompts that generalize far better than previous methods. While GOPro introduces a slight computational overhead compared to simpler methods like CoOp due to its multi-scale feature extraction, the gains in robustness make it a superior choice for real-world applications where domain shift is prevalent. Future research may explore tailoring GOPro for extreme domain shifts in fields such as medical imaging or remote sensing.

Summary updated

Abstract

Abstract
BibTeX
@inproceedings{singha2023gopro,
  author = {Mainak Singha and Ankit Jha and Biplab Banerjee},
  title = {{GOPro: Generate and Optimize Prompts in CLIP using Self-Supervised Learning}},
  booktitle = {BMVC},
  year = {2023},
  url = {https://openreview.net/forum?id=sA4WxZqbpT},
}
Figure