Word2Pix: Word to Pixel Cross-Attention Transformer in Visual Grounding

Heng Zhao, Joey Tianyi Zhou, Yew-Soon Ong

TL;DR

This paper introduces Word2Pix, a novel one-stage visual grounding model that uses a transformer's cross-attention mechanism to allow each word in a language query to directly attend to pixels in an image. This "word-to-pixel" attention approach significantly outperforms existing one-stage methods and even surpasses some two-stage methods, while maintaining real-time inference speeds.

What Problem Does This Paper Address?

Visual grounding, also known as referring expression comprehension, is the task of identifying a specific object in an image based on a natural language description. Existing one-stage methods typically encode the entire sentence into a single embedding, which is then fused with visual features. This approach can dilute the importance of individual words, especially those indicating location or relationships (like "under" or "on"), which are crucial for precise localization. Consequently, these models struggle to adapt when such critical words change, leading to incorrect grounding. Two-stage methods offer better performance but suffer from slow inference times due to region proposal steps. The paper aims to bridge this gap by developing a one-stage method that achieves high accuracy and real-time performance by focusing on word-level attention.

Methods

Word2Pix employs an encoder-decoder transformer architecture.

  • Visual Encoding Branch: A CNN backbone (ResNet-101) extracts visual features, which are then processed by a stack of transformer encoder layers. Positional encodings are added to account for the spatial nature of visual features.
  • Word-to-Pixel Attention Branch: This is the core innovation. The decoder takes individual word embeddings from the query sentence (potentially from a pre-trained BERT model or a learned embedding matrix) as queries. These queries then attend to the visual features (keys and values) from the encoder via a Multi-Head Cross-Attention (MHCA) mechanism. This allows each word to independently focus on relevant visual pixels. The attention is adjusted across multiple decoder layers.
  • Targets Prediction Head: A final prediction head uses the refined features (specifically from a [CLS] token) to perform bounding box regression, category classification, and attribute learning.

The key novelty lies in the word-to-pixel cross-attention, which contrasts with previous one-stage methods that used sentence-level embeddings or multiple sentence-level representations.

Datasets

The paper evaluates Word2Pix on three standard visual grounding datasets:

  • RefCOCO: Contains general referring expressions.
  • RefCOCO+: Similar to RefCOCO but excludes expressions with absolute location words.
  • RefCOCOg: Features longer and more complex query sentences.

All datasets primarily use images from the MSCOCO dataset.

Key Insights and Ideas

  • Word-level attention is crucial: The paper strongly demonstrates that allowing individual words to attend directly to visual pixels is significantly more effective than relying on holistic sentence embeddings for visual grounding. This is particularly important for words that define spatial relationships or attributes.
  • End-to-end training benefits visual feature extraction: By enabling gradients to propagate back to the CNN backbone, Word2Pix can fine-tune visual features specifically for the grounding task, leading to better performance compared to methods that use fixed, pre-trained visual extractors.
  • One-stage efficiency with two-stage accuracy: Word2Pix successfully achieves state-of-the-art performance among one-stage methods and even surpasses some two-stage methods, all while maintaining the real-time inference speed characteristic of one-stage approaches.

Key Results

  • Performance Improvement: Word2Pix outperforms existing one-stage methods by a significant margin (e.g., ~6.5% on RefCOCO+ testA). It also surpasses state-of-the-art two-stage methods on the tested datasets.
  • Speed: The model maintains real-time inference speeds, a key advantage over many two-stage methods.
  • Ablation Studies:
    • Word-to-pixel attention significantly outperforms sentence-to-pixel attention.
  • End-to-end training of the visual feature extractor yields substantial improvements over freezing it.
  • The impact of attribute and classification losses is less pronounced than bounding box regression, likely due to the sparsity of attribute labels in the datasets.

Limitations and Future Work

  • Computational Efficiency vs. Input Length: The paper notes that the maximum number of input tokens from a query sentence and computational efficiency remain a trade-off. They set the input word token limit to 15, as most sentences in their datasets are shorter.
  • Long and Complex Queries: While Word2Pix handles complex queries better than previous methods, it still faces challenges with very long and structurally complex sentences.
  • Future Directions: The authors suggest exploring faster convergence during training and further investigating how to better model the structure of query sentences.

Summary updated

BibTeX
@article{zhao2024word,
  author = {Heng Zhao and Joey Tianyi Zhou and Yew-Soon Ong},
  title = {{Word2Pix: Word to Pixel Cross-Attention Transformer in Visual Grounding}},
  journal = {IEEE Trans. Neural Networks Learn. Syst.},
  year = {2024},
  doi = {10.1109/tnnls.2022.3183827},
}
Figure