Online Zero-Shot Classification with CLIP

Qi Qian, Juhua Hu

Introduction

Large-scale vision-language models like CLIP have transformed zero-shot classification by aligning image and text embeddings in a shared latent space. This allows for classifying images into novel categories simply by providing class names (e.g., "a photo of a cat"). However, standard zero-shot approaches face two significant challenges: the modality gap, where text and image embeddings remain imperfectly aligned, and the distribution gap, where models fail to account for the global statistics of a specific target dataset.

Traditional solutions often rely on "offline" optimization, requiring access to the entire dataset simultaneously. This is impractical for real-time applications, such as robotics or mobile devices, where data arrives in a stream and must be processed immediately without storage. To address these limitations, we present OnZeta (Online Zero-Shot Transfer), a framework designed to refine visual class proxies and learn target distributions in real-time.

The OnZeta Framework

OnZeta introduces a dynamic, online learning approach that updates its internal representations with every incoming image. The architecture consists of two primary modules: Online Label Learning (OnLab) and Online Proxy Learning.

The OnZeta architecture integrates online proxy and label learning to refine zero-shot predictions in real-time.

Online Label Learning (OnLab)

OnLab utilizes a Lagrange dual optimization strategy to balance class assignments over time. By tracking the distribution of predicted labels, the model prevents "label collapse"—a common issue where a model over-predicts a few dominant classes. This allows OnZeta to capture the global distribution of the target task on the fly, effectively using the stream's statistics as a form of unsupervised supervision.

Online Proxy Learning and Dynamic Weighting

While standard CLIP relies on static text proxies, OnZeta learns "vision proxies" directly from incoming image features. This helps bridge the modality gap by grounding the classification in actual visual data.

A critical innovation is the Dynamic Weighting mechanism. At the beginning of a data stream, the vision proxy is based on few samples and is thus unreliable. Conversely, the text proxy is biased but stable. OnZeta employs a time-dependent trade-off ratio that initially favors the text proxy and gradually shifts confidence toward the learned vision proxy as more data is processed.

Experimental Evaluation

OnZeta was evaluated across 14 diverse datasets, including ImageNet and specialized tasks like aircraft and satellite imagery recognition.

Performance Gains

On ImageNet, OnZeta achieved 78.94% accuracy using a ViT-L/14@336 backbone, a significant improvement over the vanilla CLIP baseline of 77.02%. Across 13 downstream tasks, the framework provided an average performance boost of over 3%. Notably, OnZeta outperformed Test-time Prompt Tuning (TPT) by approximately 2% while maintaining higher computational efficiency.

Qualitative Impact

The benefit of OnZeta's distribution-aware learning is most evident in fine-grained classification tasks. For instance, in a stream containing many "Husky" images, a baseline model might misclassify them as "Alaskan Malamutes" due to visual similarity and the inherent bias in text proxies.

OnZeta corrects a misclassification by the baseline model, correctly identifying a Husky by adapting to the data stream's distribution.

As shown in the figure above, the baseline model incorrectly assigns the highest probability (32.7%) to "Alaskan Malamute." OnZeta, by learning from the stream, correctly identifies the image as a "Husky" with 23.2% confidence, successfully reordering the class hierarchy based on the observed data distribution.

Conclusion

OnZeta demonstrates that zero-shot classification can be significantly improved by treating data as a continuous stream rather than isolated points. By bridging the modality and distribution gaps through online optimization, OnZeta achieves performance levels near those of offline methods while remaining efficient enough for real-time deployment. Future work will explore extending this framework to open-vocabulary scenarios where the set of candidate classes is not known a priori.

Summary updated

BibTeX
@inproceedings{qian2024online,
  author = {Qi Qian and Juhua Hu},
  title = {{Online Zero-Shot Classification with CLIP}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-72980-5\_27},
}
Figure