Abstract
We study the visual semantic embedding problem for image-text matching. Most existing work utilizes a tailored cross-attention mechanism to perform local alignment across the two image and text modalities. This is computationally expensive, even though it is more powerful than the unimodal dual-encoder approach. This work introduces a dual-encoder image-text matching model, leveraging a scene graph to represent captions with nodes for objects and attributes interconnected by relational edges. Utilizing a graph attention network, our model efficiently encodes object-attribute and object-object semantic relations, resulting in a robust and fast-performing system. Representing captions as scene graphs offers the ability to utilize the strong relational inductive bias of graph neural networks to learn object-attribute and object-object relations effectively. To train the model, we propose losses that align the image and caption both at the holistic level (image-caption) and the local level (image-object entity), which we show is key to the success of the model. Our model is termed Composition model for Object Relations and Attributes, CORA. Experimental results on two prominent image-text retrieval benchmarks, Flickr30K and MS-COCO, demonstrate that CORA outperforms existing state-of-the-art computationally expensive cross-attention methods regarding recall score while achieving fast computation speed of the dual encoder.
Introduction
Image-text matching is a fundamental task in computer vision and natural language processing, often used for cross-modal retrieval. Historically, researchers have faced a trade-off between speed and accuracy. Dual-Encoders (e.g., CLIP) are efficient, embedding images and text independently into a shared space, but they often struggle with compositional logic—confusing "a red car and a blue house" with "a blue car and a red house." Conversely, Cross-Attention models are highly accurate by modeling fine-grained interactions but are computationally prohibitive for large-scale retrieval due to their slow inference speeds.
The Composition model for Object Relations and Attributes (CORA) bridges this gap. It is a dual-encoder architecture that achieves the accuracy of cross-attention models while maintaining the lightning-fast inference speed required for real-world applications.
Methodology: The CORA Architecture
The core innovation of CORA is representing captions as scene graphs rather than simple sequences of words. This allows the model to explicitly "bind" attributes to objects and understand complex inter-object relationships.
The framework consists of several key stages:
- Scene Graph Parsing: Input text is parsed into nodes representing objects and attributes, with edges defining their relationships (e.g., "man-riding-bicycle").
- Two-Step Graph Attention (GAT):
- Object-Attribute GAT: The model first updates object nodes using their connected attributes, creating "entity" embeddings (e.g., the concept of a "black dog").
- Object-Object Relation GAT: These entity embeddings are then updated based on their relationships with other objects in the scene.
- Multi-Level Alignment Losses: Training involves three distinct losses: a Hardest Triplet Loss for global alignment, a Contrastive Loss for local entity alignment, and a Specificity Loss to ensure the image is more similar to the complete caption than to any single constituent object.
Experiments and Results
CORA was evaluated on the Flickr30K and MS-COCO benchmarks. On Flickr30K, CORA (using a Bi-GRU text backbone) achieved an RSUM of 515.8, surpassing previous state-of-the-art dual-encoders and even some cross-attention models.
Efficiency and Robustness
A major advantage of CORA is its efficiency. For a database of 100,000 images, CORA processes a query in approximately 0.06 seconds, compared to 46 to 470 seconds for cross-attention models like NAAF or SGRAF. Furthermore, the model demonstrates robustness to parsing errors, maintaining high performance even when scene graph extraction is imperfect.
Discussion and Key Insights
- Relational Inductive Bias: By utilizing a graph structure, CORA incorporates "common sense" into the architecture, inherently understanding that attributes belong to specific objects.
- Local-to-Global Alignment: Aligning local entities (e.g., "straw hat") to image regions during training significantly improves the final global matching performance.
- Two-Step Processing: Ablation studies confirm that a sequential two-step graph process (Attributes → Objects, then Objects → Relations) outperforms joint processing, mimicking human visual perception.
Limitations and Future Work
While powerful, CORA's performance is tied to the quality of its scene graph parser. Abstract or emotional captions that lack clear object-attribute structures can be challenging. Future work includes scaling CORA to larger datasets, exploring Vision Transformers (ViT) for image features, and optimizing text encoders for the short phrases typical of scene graph nodes.
Code available at: https://github.com/vkhoi/cora_cvpr24
Summary updated