Sketch-BERT: Learning Sketch Bidirectional Encoder Representation From Transformers by Self-Supervised Learning of Sketch Gestalt

Hangyu Lin, Yanwei Fu, Xiangyang Xue, Yu-Gang Jiang

Abstract

Sketch-BERT introduces a novel framework for vector sketch representation by adapting the Transformer architecture and BERT's self-supervised pre-training. By proposing the "Sketch Gestalt" task—predicting masked points within a sketch—the model learns a robust, general-purpose representation. Experimental results on QuickDraw and TU-Berlin datasets demonstrate that Sketch-BERT significantly outperforms existing CNN and RNN-based methods in sketch recognition and retrieval tasks, while also exhibiting superior sketch completion capabilities.

Introduction

While humans perceive a sketch as a coherent, holistic object, computational representation remains challenging. Traditional approaches typically treat sketches as static pixel images (using CNNs) or as simple sequences of points (using RNNs). Pixel-based methods often ignore the temporal, stroke-based nature of drawing, while RNN-based models like SketchRNN struggle with global understanding due to their unidirectional processing. Sketch-BERT addresses this gap by capturing both local stroke details and global structure through a bidirectional Transformer architecture.

Methodology

Sketch-BERT treats a sketch as a sequence of points in vector format, where each point is a 5-element vector representing relative movement ($\Delta x, \Delta y$) and pen state.

Architecture and Embedding

The model utilizes a multi-layer bidirectional Transformer with shared weights across layers, inspired by the ALBERT architecture. To process the vector data, a novel Three-Level Embedding layer combines:

  1. Point Information: Coordinates and pen state.
  2. Positional Information: The sequential order of points.
  3. Stroke Information: The specific line segment to which a point belongs.
Sketch-BERT architecture for (a) Sketch Gestalt pre-training and (b) downstream tasks like recognition and retrieval.

Sketch Gestalt (sGesta) Pre-training

The core innovation is the "Sketch Gestalt" pre-training task. Similar to Masked Language Modeling in BERT, Sketch-BERT masks 15% of the points in a sketch. The model is trained to reconstruct the missing coordinates (via $L_1$ loss) and pen states (via cross-entropy). This forces the model to understand the underlying geometric logic and holistic structure of the object.

Experiments and Results

The model was pre-trained on the massive QuickDraw dataset (50 million sketches) and fine-tuned on both QuickDraw and the higher-quality TU-Berlin dataset.

Quantitative Performance

Sketch-BERT established new state-of-the-art benchmarks:

  • Sketch Recognition: Achieved 88.30% Top-1 accuracy on QuickDraw and 76.30% on TU-Berlin, significantly surpassing previous CNN and RNN baselines.
  • Sketch Retrieval: Reached a Mean Average Precision (mAP) of 78.87% on QuickDraw for category-level retrieval.
  • Efficiency: Pre-trained models converged nearly 10x faster during fine-tuning compared to training from scratch.

Qualitative Analysis

The "Sketch Gestalt" approach allows the model to effectively "hallucinate" missing parts of complex drawings. As shown in Figure 2, Sketch-BERT can accurately reconstruct intricate details like the strings of a guitar or the legs of a cat from highly sparse inputs.

Qualitative results of the Sketch Gestalt task showing ground truth, masked input, and Sketch-BERT reconstruction.

Discussion and Conclusion

A key insight from this work is that bidirectional context is crucial for sketch understanding; the model can leverage later strokes to interpret earlier ones. Ablation studies further revealed that predicting point positions ($\Delta x, \Delta y$) is a more effective pre-training task than predicting pen states, as it emphasizes the learning of actual geometry.

While highly effective, the Sketch Gestalt task can be challenging for extremely messy or complex drawings where stroke logic is ambiguous. Future work may extend Sketch-BERT to Sketch-Based Image Retrieval (SBIR) and more advanced generative creative assistance.

Summary updated

BibTeX
@inproceedings{lin2020sketch,
  author = {Hangyu Lin and Yanwei Fu and Xiangyang Xue and Yu-Gang Jiang},
  title = {{Sketch-BERT: Learning Sketch Bidirectional Encoder Representation From Transformers by Self-Supervised Learning of Sketch Gestalt}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2020},
  doi = {10.1109/cvpr42600.2020.00679},
}
Figure