Contextual Visual Similarity

Xiaofang Wang, Kris M. Kitani, Martial HebertarXiv 2016

Introduction

In computer vision, similarity is often treated as an objective, fixed property—typically defined by category labels. However, visual similarity is inherently multi-faceted and context-dependent. For instance, from a category perspective, a black dog is most similar to a white dog. Conversely, from a color perspective, that same black dog shares more commonality with a black horse.

Conceptual illustration of contextual similarity: a black dog can be similar to a white dog by category or a black horse by color.

Standard image search engines often default to category-level similarity. To search for specific attributes like "running" or "yellow" without pre-trained classifiers, systems must handle the ambiguity of user intent. This paper introduces "Contextual Visual Similarity," a framework that dynamically learns instance-specific feature weights to navigate these different "mental perspectives."

Methodology

The proposed framework represents context through image triplets consisting of a Query ($q$), a Positive ($p$), and a Negative ($n$). This triplet serves to disambiguate the user's intent.

Feature Reweighting

Rather than retraining a deep neural network, the authors leverage high-level features from a pre-trained VGGNet. They learn a diagonal weight matrix $W$ (represented as a vector $w$) that transforms the feature space on the fly. The objective is to find a $w$ such that the distance between the query and positive image is minimized, while the distance to the negative image is maximized.

Dual-Margin Loss and Regularization

To optimize the weights, a specialized loss function with two distinct margins is employed:

  • Positive Margin ($\alpha_p$): Prevents the query and positive images from being pushed too close, which helps avoid overfitting to specific noise.
  • Negative Margin ($\alpha_n$): Ensures the negative image is sufficiently separated from the query in the reweighted space.

Additionally, a regularization term is included to maintain a unit norm for the reweighted features, preventing the weight vector from collapsing or exploding. This learned vector $w$ effectively acts as a mask, amplifying relevant dimensions (e.g., color-related features) while suppressing irrelevant ones.

Experimental Setup

The authors evaluated their approach using a custom version of the VAQA dataset, comprising 2,197 images across 8 categories (e.g., bird, car, dog) and 8 attributes (e.g., red, running, swimming). The dataset contains 38 distinct category-attribute combinations. Image representations were extracted from the pool5 and fc7 layers of VGGNet.

Key Results and Insights

The contextual approach demonstrated significant improvements over standard VGG feature baselines.

Image Retrieval and Analogies

In attribute-specific searches, the method outperformed the baseline by 11% to 22% in Mean Average Precision (MAP). The system also excelled at "visual analogy" tasks (e.g., "A is to B as C is to ?").

Performance curves for Action and Color analogies, showing the proposed method consistently outperforming the baseline.

As shown in the analogy results, the model significantly improves recall for both action-based and color-based relationships compared to standard vector subtraction methods.

Emergent Semantic Clusters

By analyzing the learned weight vectors ($w$) across thousands of random triplets, the authors found that the model unsupervisedly discovers semantic concepts. Clusters emerged for attributes like "grass" or "brown," even though the model was never explicitly trained on these labels. This suggests the reweighting mechanism successfully captures latent visual properties.

Conclusion and Future Work

Contextual Visual Similarity provides a flexible way to handle ambiguous search queries without requiring exhaustive attribute labeling. While powerful, the method is currently limited by the representational capacity of the underlying pre-trained model. Future research may focus on automatically inferring triplets from user behavior (e.g., clicks) or integrating natural language cues to further refine the search context.

Summary updated

BibTeX
@misc{wang2016contextual,
  author = {Xiaofang Wang and Kris M. Kitani and Martial Hebert},
  title = {{Contextual Visual Similarity}},
  year = {2016},
  eprint = {1612.02534},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1612.02534},
}
Figure