SGEdit: Bridging LLM with Text2Image Generative Model for Scene Graph-based Image Editing

Zhiyuan Zhang, Dongdong Chen, Jing Liao

Introduction

While Text-to-Image (T2I) diffusion models like Stable Diffusion have revolutionized image generation, precise and intuitive image editing remains a significant challenge. Traditional text-guided editing often lacks the spatial granularity required for complex modifications, frequently resulting in unintended changes to the background or the loss of specific object identities. Scene graphs—structured representations where nodes denote objects and edges denote their relationships—offer a promising alternative for high-level control. However, previous scene-graph-based methods were often limited by low-fidelity outputs or restricted object categories.

SGEdit addresses these limitations by introducing a framework that leverages Large Language Models (LLMs) as a "controller" to bridge the gap between structured scene graphs and high-fidelity diffusion models. By treating the scene graph as a user interface, SGEdit enables precise, localized edits while maintaining the visual integrity of the original scene.

Methodology

The SGEdit pipeline is structured into two primary phases: Scene Parsing & Concept Learning, and Image Editing via an LLM Controller.

1. Scene Parsing and Concept Learning

To initiate the process, an LLM (such as GPT-4V) analyzes the input image to construct a comprehensive scene graph and generate detailed descriptions for each identified object. This is paired with Grounded-SAM, an open-vocabulary segmenter, to create precise masks for these objects.

A critical innovation in SGEdit is its Residual Concept Learning strategy. To preserve the specific visual identity of an object (e.g., a unique toy or a specific person), the system fine-tunes the diffusion model using a hybrid approach. Each object is represented by a combination of a unique optimized token (capturing fine-grained visual details) and a detailed text prompt (capturing general semantics and pose). This dual representation ensures that the model can modify an object's position or relationship without losing its distinct identity.

2. Image Editing via LLM Controller

When a user modifies the scene graph—for instance, by moving an object or changing a relationship—the LLM acts as a spatial reasoner. It translates these graph-level changes into a sequence of discrete "remove" and "insert" operations.

To ensure these edits are localized and do not affect the rest of the image, the framework employs Attention-modulated Object Removal and Insertion. By manipulating the self-attention and cross-attention maps within the diffusion model, the system can effectively "erase" an object and "paint" a new one into a specific bounding box. This method ensures that the background texture is preserved and that the new object is seamlessly integrated into the scene.

Experimental Evaluation

SGEdit was evaluated using a combination of in-the-wild images and established benchmarks:

  • In-the-wild Dataset: 30 diverse images featuring 120 unique edits.
  • EditVal: A benchmark for text-guided image editing.
  • PIE-Bench: A benchmark focused on addition, replacement, and relationship changes.

Key Results

SGEdit demonstrated significant improvements over existing baselines such as SIMSG, SGDiff, and InstructPix2Pix:

  • User Preference: In human evaluations, SGEdit was preferred 80% of the time for element composition and 82% of the time for relationship compliance.
  • Quantitative Performance: On the EditVal benchmark, SGEdit achieved an editing accuracy of 0.53, nearly doubling the performance of the next best baseline, Break-A-Scene (0.22).
  • Fidelity and Preservation: On PIE-Bench, the model maintained high background preservation (PSNR of 22.45) and the best structure distance (0.06), indicating that edits were localized and precise.

Discussion and Insights

The success of SGEdit stems from two primary insights. First, the Residual Advantage of combining optimized tokens with semantic text prompts allows the model to balance identity preservation with flexibility. Second, the use of LLMs as Spatial Reasoners allows for more natural object placement; the LLM can infer appropriate bounding boxes based on contextual relationships (e.g., "on top of") more effectively than traditional layout models.

Limitations and Future Work

Despite its performance, SGEdit faces several challenges. The current process requires 6–10 minutes of fine-tuning per image, making it unsuitable for real-time applications. Additionally, the quality of the edit is heavily dependent on the initial accuracy of the scene parser and segmenter. Future research will focus on accelerating the concept learning phase and improving the physical consistency of lighting and shadows for newly inserted objects through iterative refinement between the LLM and the generative model.

Summary updated

BibTeX
@article{zhang2024sgedit,
  author = {Zhiyuan Zhang and Dongdong Chen and Jing Liao},
  title = {{SGEdit: Bridging LLM with Text2Image Generative Model for Scene Graph-based Image Editing}},
  journal = {ACM Trans. Graphics},
  year = {2024},
  doi = {10.1145/3687957},
}
Figure