PerceptionCLIP: Visual Classification by Inferring and Conditioning on Contexts

Bang An, Sicheng Zhu, Michael-Andrei Panaitescu-Liess, Chaithanya Kumar Mummadi, Furong Huang

TL;DR

PerceptionCLIP is a training-free, two-step method that improves CLIP’s zero-shot classification by mimicking human perception. It first identifies contextual attributes (like background or orientation) and then uses that context to more accurately classify the main object, significantly boosting robustness against misleading "spurious" features.

What Problem Does This Paper Address?

Vision-language models like CLIP have revolutionized zero-shot classification—the ability to recognize objects the model wasn't explicitly trained on by matching images to text descriptions. However, standard CLIP often relies on a "bag-of-words" style matching that can be easily fooled by its training data.

For example, if CLIP frequently saw "waterbirds" in front of water during training, it might learn a spurious correlation: "water = waterbird." If you show it a land bird standing near a lake, it might incorrectly label it a waterbird simply because of the background.

The authors argue that current methods treat classification as a simple text-retrieval task, ignoring the hierarchical nature of human vision. When humans look at an image, we don't just see an object in a vacuum; we unconsciously perceive the scene layout, lighting, and orientation first. This contextual understanding then helps us isolate and identify the foreground object.

Methods: A Two-Step Perception Process

To address these limitations, the authors introduce PerceptionCLIP, a two-step inference process that requires no additional training or fine-tuning of the underlying model.

Overview of PerceptionCLIP compared to standard zero-shot CLIP inference, including Grad-CAM visualizations.
  1. Step 1: Context Inference: Given an image, the model first uses CLIP to estimate the probability of various "contextual attributes" (e.g., is the image upside-down? Is the background a forest or a beach?). The authors introduce an attribute-aware CLIP score to handle this initial assessment.
  2. Step 2: Conditional Classification: The model then predicts the object's class by "conditioning" on these inferred attributes. Instead of just asking "Is this a dog?", it essentially asks "Given that this image is on grass and is upright, is this a dog?"

Technically, this involves marginalizing over the inferred attributes. The model calculates a weighted sum of class probabilities across all possible attribute combinations, where the weights are determined by how likely those attributes are in the first step. Conceptually, this process mirrors the "Chain-of-Thought" prompting often used to improve reasoning in Large Language Models (LLMs).

Datasets and Evaluation

The researchers evaluated PerceptionCLIP across a wide range of benchmarks to test its versatility and robustness:

  • Generalization: ImageNet and its "out-of-distribution" variants (ImageNetV2, ImageNet-R, ImageNet-A, and ImageNet-Sketch).
  • Domain-Specific: CUB200 (birds), EuroSAT (satellite imagery), Places365 (scenes), Flowers102, Food101, and Oxford Pets.
  • Group Robustness: Waterbirds (testing if the model is distracted by backgrounds) and CelebA (testing if hair color classification is biased by gender or age).

Key Insights and Ideas

  • CLIP is its own best context-clue: One of the most surprising findings is that CLIP is already quite adept at identifying its own context. It can infer attributes like orientation or image corruption with roughly 74% accuracy on ImageNet, despite never being explicitly trained for those specific tasks.
  • Context acts as a "De-noiser": By explicitly naming the background (e.g., "on the grass"), the model effectively "subtracts" that information from the classification task. Grad-CAM visualizations confirm that when context is provided, the model's attention shifts away from the background and focuses more intensely on the "core features" of the object.
  • Prompt Ensembling is "Implicit Perception": The authors suggest that the common practice of averaging 80 different prompt templates works because it acts as an ad-hoc way of covering different potential contexts. PerceptionCLIP serves as a more systematic, explicit, and effective version of this intuition.

Key Results

  • Superior Generalization: PerceptionCLIP consistently outperformed standard CLIP and prompt ensembling across 11 different datasets. Notably, it achieved a 5% accuracy gain on EuroSAT satellite imagery.
  • Massive Robustness Gains: On the Waterbirds dataset, PerceptionCLIP reduced the "accuracy gap" between the easiest and hardest groups by 19%. This indicates the model is far less likely to be tricked by a bird appearing in an unusual background.
  • Improved Interpretability: Because the model first outputs its inferred context, users can see why a model made a certain choice (e.g., "I think this is a dog because I've already identified that it's an upright photo on grass").

Limitations and Future Work

  • Sensitivity to Phrasing: Like most prompt-based methods, PerceptionCLIP is sensitive to the specific words used to describe attributes. Using "upright" versus "upstanding" can lead to different results.
  • Manual Attribute Selection: Currently, the "contextual attributes" (like background or lighting) are often manually chosen based on the dataset. While the authors experimented with using GPT-4 to automatically discover these attributes, fully automating this process remains a challenge.
  • Computational Overhead: Marginalizing over many attribute combinations requires more passes through CLIP's text encoder. However, the authors note these text embeddings can be pre-computed to save time during actual inference.

Summary updated

BibTeX
@inproceedings{an2024perceptionclip,
  author = {Bang An and Sicheng Zhu and Michael-Andrei Panaitescu-Liess and Chaithanya Kumar Mummadi and Furong Huang},
  title = {{PerceptionCLIP: Visual Classification by Inferring and Conditioning on Contexts}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=2Oiee202rd},
}
Figure