Hierarchy-Based Image Embeddings for Semantic Image Retrieval

Björn Barz, Joachim Denzler

TL;DR

This paper introduces a deterministic method to align deep learning image features with structured world knowledge. By mapping images onto a hypersphere where distances between class centroids reflect their positions in a semantic hierarchy (like WordNet), the authors create retrieval systems that "fail gracefully"—ensuring that if a system can't find a specific dog breed, it returns other dogs rather than visually similar but unrelated objects like mops or fried chicken.

What Problem Does This Paper Address?

Standard Convolutional Neural Networks (CNNs) are excellent at classification, but their internal representations often prioritize visual similarity (color, texture, shape) over semantic similarity (meaning). In Content-Based Image Retrieval (CBIR), this leads to "semantic inconsistency."

For example, a standard CNN might see a green apple and a tennis ball as highly similar because they are both round and neon green. However, semantically, a green apple is much closer to a red apple. Current solutions, like triplet loss or metric learning, are computationally expensive to train because they require complex "hard-negative mining." Furthermore, they often cluster members of the same class together but ignore the global relationships between different classes. This paper aims to bake the "logic" of the real world—represented as a hierarchy—directly into the image features.

Methods

The authors propose a two-step approach to bridge the gap between pixels and semantics:

  1. Deterministic Class Embeddings: Instead of learning class representations from scratch, the authors use a deterministic algorithm to project classes onto a unit hypersphere. They derive a similarity score ($s_G$) from a tree-based hierarchy (like WordNet or a biological taxonomy). The algorithm ensures that the dot product between any two class vectors exactly matches their semantic similarity. This process is $O(n^3)$ but only needs to be done once before training.
  2. Correlation Loss: The CNN is trained to map an image to the specific coordinates of its class's pre-calculated centroid. The loss function is remarkably simple: it maximizes the cosine similarity (dot product) between the image feature and its target class embedding.

Crucially, this method avoids the need for pairs or triplets of images during training, making it much more efficient than standard metric learning. The authors also provide a way to use eigendecomposition to create low-dimensional approximations for datasets with thousands of classes.

Datasets

The authors evaluated their approach on three widely used benchmarks:

  • CIFAR-100: 100 classes of general objects. The authors created a custom tree-structured taxonomy based on WordNet for this dataset.
  • North American Birds (NABirds): 555 species of birds. This dataset includes a 5-level deep biological hierarchy, making it ideal for testing fine-grained semantic retrieval.
  • ImageNet (ILSVRC 2012): 1,000 classes. Since WordNet is a Directed Acyclic Graph (DAG) rather than a strict tree, the authors used a pruning method to derive a tree-shaped hierarchy for their algorithm.

Key Insights and Ideas

  • Semantic Gracefulness: The "aha moment" is visible in the retrieval results. When querying an "orange" (the fruit), standard models eventually return orange-colored clocks or bowls. This model instead returns apples and pears—items that are visually different but semantically related.
  • No Mining Required: By providing fixed "anchor" points in the feature space based on prior knowledge, the model learns global structure without the expensive overhead of finding "hard" examples to contrast against.
  • Classification vs. Retrieval: The authors show that optimizing for classification (cross-entropy) actually produces sub-optimal features for retrieval. Their semantic embedding loss can be used alone or combined with cross-entropy to get the best of both worlds.
  • Dimensionality Flexibility: While a perfect embedding of $n$ classes requires $n$ dimensions, the authors found that even significantly reducing the dimensionality (e.g., using only 16 dimensions for 555 bird species) still outperformed standard baselines.

Key Results

The primary metric used was mean Average Hierarchical Precision (mAHP), which rewards the model for retrieving "near misses" (e.g., a different dog breed) more than "total misses" (e.g., a car).

  • Retrieval Performance: The proposed method outperformed the second-best competitors by 5–23% on CIFAR-100, a staggering 36–74% on NABirds, and 16% on ImageNet.
  • Classification: Despite not being the primary goal, the semantic embeddings achieved classification accuracy comparable to (and sometimes better than) standard cross-entropy models, particularly on the NABirds dataset where the hierarchy helped the model learn from limited data.

Limitations and Future Work

  • Tree Constraint: The current algorithm assumes the hierarchy is a tree. While many ontologies (like biological taxonomies) are trees, others are complex graphs (DAGs). Adapting the algorithm to handle overlapping hierarchies without manual pruning is a clear next step.
  • Generalization to Novel Classes: The embedding space is currently fixed to the classes seen during training. The authors suggest that investigating earlier layers of the network might reveal features that generalize better to entirely new, unseen categories.
  • Hierarchy Quality: The model is only as good as the hierarchy provided. If the underlying taxonomy is flawed or overly simplified, the resulting embeddings will reflect those errors.

Summary updated

BibTeX
@inproceedings{barz2019hierarchy,
  author = {Björn Barz and Joachim Denzler},
  title = {{Hierarchy-Based Image Embeddings for Semantic Image Retrieval}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2019},
  url = {https://openreview.net/forum?id=-SwJnXfIeXq},
}
Figure