EGTR: Extracting Graph from Transformer for Scene Graph Generation

Jinbae Im, JeongYeon Nam, Nokyung Park, Hyungmin Lee, Seunghyun Park · DOI

Abstract

Scene Graph Generation (SGG) aims to represent images as structured graphs of objects and their relationships. Traditional methods often rely on complex multi-stage pipelines or heavy triplet-based detectors. We present EGTR (Extracting Graph from TRansformer), a lightweight, one-stage model that "recycles" the internal self-attention weights of a DETR-based object detector to predict relationships. By leveraging these existing computational by-products, EGTR achieves state-of-the-art accuracy on Visual Genome and Open Image V6 while maintaining the fastest inference speed and smallest parameter count in its class.

Introduction

Scene Graph Generation (SGG) is a fundamental task in computer vision that bridges the gap between perception and reasoning. It involves detecting objects (nodes) and identifying their semantic interactions (edges). Historically, SGG followed a two-stage approach: detecting objects first and then classifying relations between all pairs. This often leads to high computational costs and error propagation. Recent one-stage models attempted to detect "triplets" directly but struggled with "lonely" objects—those without defined relations—and required significant architectural overhead.

EGTR addresses these challenges by observing that Transformer-based detectors like DETR already compute relationships between object queries via multi-head self-attention. Instead of building a new relation module from scratch, EGTR extracts these existing attention weights to form the basis of a scene graph.

Methodology: Efficiency Through Reuse

The core innovation of EGTR is its ability to generate scene graphs by minimally extending a standard object detector.

Relation Extraction from Attention

The model extracts query and key representations from each layer of the DETR decoder. These representations are treated as potential features for subjects and objects. By analyzing the self-attention maps, the model identifies pairs of queries that are likely to have a relationship.

The EGTR architecture leverages internal self-attention from a DETR-based detector to extract relations.

Gated Sum Aggregation and Adaptive Smoothing

Since different layers of the Transformer capture varying levels of semantic and spatial detail, EGTR employs a gated sum aggregation mechanism to combine multi-layer features into a unified relational representation.

To synchronize the learning of object detection and relation extraction, the authors introduced Adaptive Smoothing. Early in training, when object detection is unreliable, the model uses the bipartite matching cost of the detector to adjust relationship labels. This curriculum-based approach prevents the relation head from being penalized for errors caused by the underlying detector.

Key Insights: Attention as a Proxy for Relations

A significant finding of this work is that high attention weights in a standard DETR model correlate strongly with semantic relationships. As shown in the visualization below, the internal attention mechanism naturally focuses on interacting objects, providing a "free" foundation for scene graph construction.

Comparison between the ground-truth scene graph and the extracted attention weights, demonstrating how attention serves as a proxy for semantic relationships.

Furthermore, by maintaining a standard object detection pipeline, EGTR avoids the "lonely object" problem common in triplet-based models. It can detect background objects like trees or buildings even if they are not part of a specific relationship triplet, leading to higher overall detection accuracy (mAP).

Experimental Results

EGTR was evaluated on the Visual Genome (VG) and Open Image V6 (OI V6) benchmarks.

  • Efficiency: With only 42.5M parameters, EGTR is significantly smaller than competing one-stage models (e.g., 1.5x smaller than SSR-CNN and 6.5x smaller than SGTR).
  • Inference Speed: It achieves 14.7 FPS on a V100 GPU, making it the fastest one-stage SGG model to date.
  • Accuracy: On Visual Genome, EGTR achieved an AP50 of 30.8, outperforming previous state-of-the-art one-stage methods. On Open Image V6, it reached a score of 48.6.
  • Qualitative Quality: Visualizations show that EGTR produces cleaner, less redundant bounding boxes compared to triplet-based models, which often produce overlapping detections.

Conclusion and Future Work

EGTR demonstrates that complex scene graphs can be extracted efficiently by looking at the internal workings of Transformer-based detectors. By "recycling" attention weights and using adaptive smoothing to manage training uncertainty, EGTR provides a high-performance, lightweight solution for real-time scene understanding.

However, the model remains dependent on the backbone detector's performance; missed objects cannot be recovered by the relation head. Additionally, zero-shot relationship prediction remains a challenge, with the model achieving a modest 2.1 zR@50. Future work may explore improving zero-shot capabilities and applying this attention-extraction paradigm to other multimodal Transformer architectures.

Summary updated

BibTeX
@inproceedings{im2024egtr,
  author = {Jinbae Im and JeongYeon Nam and Nokyung Park and Hyungmin Lee and Seunghyun Park},
  title = {{EGTR: Extracting Graph from Transformer for Scene Graph Generation}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2024},
  doi = {10.1109/cvpr52733.2024.02287},
}
Figure