Zero-Shot Everything Sketch-Based Image Retrieval, and in Explainable Style

Fengyin Lin, Mingkang Li, Da Li, Timothy M. Hospedales, Yi-Zhe Song, Yonggang Qi

Abstract

Traditional Zero-Shot Sketch-Based Image Retrieval (ZS-SBIR) methods often rely on external semantic knowledge, such as word embeddings, to bridge the domain gap between sparse sketches and textured photos. This paper introduces a novel transformer-based framework that reframes ZS-SBIR as a local patch-matching problem. By focusing on "shareable" local visual correspondences, the proposed model achieves state-of-the-art performance across category-level, fine-grained, and cross-dataset settings using a single architecture. Furthermore, the model provides inherent explainability through a unique sketch-to-photo synthesis process, demonstrating that the network accurately identifies structural correspondences between modalities.

Introduction

Sketch-Based Image Retrieval (SBIR) is a challenging computer vision task due to the inherent domain gap: sketches are iconic, sparse, and lack the texture and color information present in photos. The "Zero-Shot" (ZS) variant adds a layer of complexity, requiring models to retrieve images from categories unseen during training.

Historically, researchers have bridged this gap by mapping both sketches and photos into a common semantic space using external data like Word2Vec. However, this approach often ignores the fine-grained visual details that distinguish specific sketches and relies heavily on the quality of external semantic embeddings. Moreover, these models typically function as "black boxes," offering little insight into why a specific sketch was matched to a particular photo. This paper proposes a shift from global semantic mapping to a "bag-of-local-matches" approach, leveraging the idea that while a category might be new, its constituent parts are often universal.

Methodology

The proposed framework utilizes a transformer-based cross-modal network designed to identify local correspondences between sketches and photos. The architecture consists of four primary innovations:

1. Learnable Tokenizer

Standard Vision Transformers (ViT) typically split images into rigid, non-overlapping patches. In the context of sketches, this often results in many uninformative tokens representing empty white space. To combat this, the authors implement a CNN-based tokenizer that captures structural cues and local context, ensuring that the resulting tokens contain meaningful information even in sparse regions of the sketch.

2. Self-Attention with a [Ret] Token

Similar to the [CLS] token used in BERT for text classification, the authors introduce a learnable [Ret] (retrieval) token. This token is designed to capture the global representation of the image or sketch, while the remaining tokens are free to focus on specific local features.

3. Cross-modal Attention

The core of the matching process lies in the cross-modal attention mechanism. By swapping "queries" between the sketch and photo branches, the network is forced to find direct local correspondences. It essentially asks: "Which specific part of this photo most closely resembles this specific stroke in the sketch?"

4. Kernel-based Relation Network

Rather than relying on a simple similarity score, the model employs a small neural network to analyze a "kernel matrix" of all patch-to-patch matches. This allows the system to learn which correspondences—such as the specific curve of a deer's antlers—are most critical for a successful retrieval, effectively weighting important features over background noise.

Explainability via Synthesis

To validate that the model is looking at the correct features, the authors developed a "sketch-to-photo synthesis" method. By replacing every patch of a sketch with its most similar patch from a retrieved photo, they create a composite image. These "Frankenstein" images clearly resemble the original sketch's structure using photo-realistic textures, providing visual proof that the model's retrieval logic is based on accurate structural matching rather than abstract or accidental correlations.

Experimental Results

The model was evaluated across several benchmark datasets, including TU-Berlin Ext, Sketchy Ext, and QuickDraw Ext (the largest available dataset with 330,000 sketches).

  • Category-Level Performance: On the TU-Berlin Ext dataset, the model achieved a Mean Average Precision (mAP) of 0.569, a significant improvement over previous state-of-the-art models like SAKE (0.475).
  • Fine-Grained Retrieval: The architecture demonstrated remarkable versatility. In tests on the QMUL-Chair-V2 dataset, it achieved 64.31% top-1 accuracy, outperforming specialized models that were trained specifically on those categories.
  • Efficiency: By implementing "Token Selection"—a process of discarding uninformative background patches—the authors reduced computational costs by over 60% with negligible impact on retrieval accuracy.

Conclusion and Future Work

This research demonstrates that "local is universal." By focusing on granular visual correspondences rather than abstract global semantics, the model successfully transfers knowledge to unseen categories without the need for external word embeddings. While the current sketch-to-photo synthesis is coarse and results in blocky images, it serves as a powerful tool for model explainability.

Future work will focus on refining the synthesis process to produce smoother transitions and addressing the "global shape" problem. Currently, the model occasionally produces false positives when local parts match but the overall configuration is incorrect (e.g., confusing the blades of a windmill with the blades of scissors). Balancing local detail with global structural constraints remains the next frontier for this architecture.

Summary updated

BibTeX
@inproceedings{lin2023zero,
  author = {Fengyin Lin and Mingkang Li and Da Li and Timothy M. Hospedales and Yi-Zhe Song and Yonggang Qi},
  title = {{Zero-Shot Everything Sketch-Based Image Retrieval, and in Explainable Style}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
  doi = {10.1109/cvpr52729.2023.02236},
}
Figure