Modality-Aware Triplet Hard Mining for Zero-shot Sketch-Based Image Retrieval

Zongheng Huang, Yifan Sun, Chuchu Han, Changxin Gao, Nong SangarXiv 2021

Introduction

Sketch-based image retrieval (SBIR) allows users to find specific photos using intuitive hand-drawn queries. However, this task is complicated by the "modality gap"—the significant visual difference between sparse, black-and-white sketches and dense, colorful photos. The challenge is further amplified in "zero-shot" scenarios (ZS-SBIR), where the model must retrieve images from categories it has never encountered during training.

In "Modality-Aware Triplet Hard Mining for Zero-shot Sketch-Based Image Retrieval," researchers from HUST and Baidu Research introduce MATHM, a framework designed to bridge these gaps by optimizing the feature space through specialized triplet losses and a dynamic weighting mechanism.

The Dual Challenge: Modality and Category Gaps

ZS-SBIR requires overcoming two primary hurdles:

  1. The Modality Gap: The model must map sketches and photos into a shared embedding space where semantic similarity overrides stylistic differences.
  2. The Category Gap: Since test categories are unseen, the model cannot rely on class-specific memorization. It must learn a robust metric space that generalizes category discrimination to new, unseen objects.

Methodology: The MATHM Framework

The MATHM framework builds upon a baseline of classification and cross-modality pairwise training. Its core innovation lies in the simultaneous use of three distinct triplet types to refine the embedding space.

The MATHM framework overview, detailing the PK-sampling strategy, the deep model, and the integration of three triplet loss types with a gradient-based weighting module.

Specialized Triplet Losses

MATHM employs three "flavors" of triplets to address different aspects of the problem:

  • Cross-Modality Triplets: These align sketches with their corresponding photos while pushing away photos of different categories.
  • Within-Modality Triplets: These ensure that sketches of different categories (and photos of different categories) remain distinct within their own domains, preventing category collapse.
  • Hybrid Triplets: This configuration uses a sketch anchor, a photo positive, and a sketch negative. It specifically forces the model to prioritize category identity over modality, pulling the cross-modal positive closer than the same-modal negative.

Gradient-Based Dynamic Weighting

A significant challenge in multi-task learning is balancing different loss functions that may converge at different rates. If one loss produces much larger gradients than the others, it can dominate the training process. MATHM introduces an adaptive weighting scheme that monitors the gradient magnitudes of each triplet loss and dynamically adjusts their influence, ensuring balanced optimization throughout the training process.

Experimental Results and Insights

The model was evaluated on the TU-Berlin Extended and Sketchy Extended benchmarks, achieving state-of-the-art performance.

Qualitative comparison of the embedding space between the baseline and MATHM, showing improved category separation and modality alignment.

Quantitative Performance

  • TU-Berlin: MATHM reached a Mean Average Precision (mAP) of 50.82%, a notable improvement over previous methods like SAKE (~47.5%).
  • Sketchy: The model achieved 62.92% mAP, outperforming the baseline by over 4%.

Qualitative Analysis

The effectiveness of MATHM is most visible in the organization of the feature space. By prioritizing category separability alongside modality alignment, MATHM avoids the "category collapse" often seen in GAN-based approaches. The "Hybrid Triplet" acts as the "secret sauce," teaching the model that category identity is a more critical signal than image style. Furthermore, the use of "Hard Mining"—selecting the most challenging examples in each training batch—forces the model to learn the most difficult distinctions, leading to better generalization on unseen classes.

Conclusion

Modality-Aware Triplet Hard Mining (MATHM) represents a significant step forward in Zero-Shot Sketch-Based Image Retrieval. By combining specialized triplet losses with a novel gradient-based weighting scheme, the framework effectively bridges the modality gap while maintaining high category discriminability. While challenges remain regarding the inherent ambiguity of human sketches, MATHM sets a new benchmark for robust, cross-modal retrieval in unseen domains.

Summary updated

BibTeX
@misc{huang2021modality,
  author = {Zongheng Huang and Yifan Sun and Chuchu Han and Changxin Gao and Nong Sang},
  title = {{Modality-Aware Triplet Hard Mining for Zero-shot Sketch-Based Image Retrieval}},
  year = {2021},
  eprint = {2112.07966},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2112.07966},
}
Figure