Diffusion-Based Scene Graph to Image Generation with Masked Contrastive Pre-Training

Ling Yang, Zhilin Huang, Yang Song, Shenda Hong, Guohao Li, Wentao Zhang, Bin Cui, Bernard Ghanem, Ming-Hsuan YangarXiv 2022 · DOI

Abstract

SGDiff is a novel framework for high-quality image generation from scene graphs. By replacing traditional, manually-designed layout bottlenecks with learned embeddings, SGDiff achieves superior semantic alignment and image realism. The approach utilizes a two-stage process: masked contrastive pre-training of a scene graph encoder followed by image synthesis via a latent diffusion model. Experimental results on Visual Genome and COCO-Stuff benchmarks demonstrate state-of-the-art performance in both quantitative metrics and qualitative visual quality.

Introduction

Generating images from scene graphs—structured representations where nodes are objects and edges are relationships—offers a powerful mechanism for controlled image synthesis. However, mapping these abstract graphs to pixel-level detail is a significant challenge. Most existing methods rely on an intermediate "scene layout" step, consisting of manually crafted bounding boxes and masks.

These layouts often act as a lossy bottleneck, failing to capture complex semantic nuances (e.g., "eating" vs. "looking at") or overlapping spatial relations. Because these layouts are not optimized for the specific generation task, the resulting images often lack fine-grained detail or fail to accurately reflect the input graph's instructions. SGDiff addresses this by ditching manual layouts in favor of learned embeddings that capture both local structural details and global scene composition.

Methodology

SGDiff replaces manual layouts with a two-stage learning process designed to maximize semantic fidelity and image quality.

Stage 1: Masked Contrastive Pre-Training

Instead of explicitly defining object coordinates, the model trains a scene graph encoder to learn the direct relationship between graphs and images through two self-supervised tasks:

  • Local (Masked Autoencoding): The model masks specific objects in an image and reconstructs them using information from corresponding scene graph triplets. This forces the encoder to learn fine-grained, local structural details.
  • Global (Contrastive Learning): Similar to CLIP, the model learns to align entire scene graphs with their corresponding images in a shared embedding space, capturing the overall scene composition.

Stage 2: Latent Diffusion Generation

The pre-trained encoder's embeddings are integrated into a Latent Diffusion Model (LDM). The LDM uses cross-attention to condition the denoising process on the scene graph embeddings within a compressed latent space. This allows for the generation of high-resolution images that are both realistic and semantically precise.

Overview of the two-stage SGDiff framework: Stage 1 involves masked contrastive pre-training, and Stage 2 utilizes a latent diffusion model for image generation.

Experiments and Results

SGDiff was evaluated on two standard benchmarks: Visual Genome (VG), featuring dense annotations for over 108,000 image-graph pairs, and COCO-Stuff, which includes 40,000 training images with synthesized scene graphs.

Quantitative Performance

SGDiff significantly outperforms previous state-of-the-art (SOTA) models like Sg2Im and PasteGAN across multiple resolutions. On the COCO-Stuff (256x256) benchmark:

  • FID (Fréchet Inception Distance): SGDiff achieved a score of 36.2, a substantial improvement over PasteGAN’s 79.1 (lower is better).
  • Inception Score (IS): The model improved the score from 12.3 to 17.8 (higher is better).

Qualitative Comparison

Visual results demonstrate that SGDiff produces much sharper objects and more realistic textures compared to the often blurry or distorted outputs of GAN-based predecessors. The model also exhibits superior semantic alignment, accurately rendering complex relationships specified in the scene graph.

Qualitative comparison between Sg2Im, PasteGAN, and SGDiff. SGDiff produces images with higher realism and better adherence to the input scene graphs.

Discussion and Conclusion

A key insight of this work is that explicit layout bottlenecks are unnecessary for effective spatial control; learned embeddings can capture spatial and semantic nuances more effectively. The combination of local reconstruction and global alignment is critical for achieving both object-level accuracy and overall scene coherence. Furthermore, the model enables "scene graph surgery," allowing users to modify specific nodes or relationships while the diffusion model updates the image contextually.

While SGDiff sets a new standard for scene-to-image generation, it remains dependent on the quality of the input graph. Future work may explore extending this pre-training strategy to other structured inputs or integrating it into larger-scale text-to-image models to enhance spatial reasoning capabilities.

Summary updated

BibTeX
@misc{yang2022diffusion,
  author = {Ling Yang and Zhilin Huang and Yang Song and Shenda Hong and Guohao Li and Wentao Zhang and Bin Cui and Bernard Ghanem and Ming-Hsuan Yang},
  title = {{Diffusion-Based Scene Graph to Image Generation with Masked Contrastive Pre-Training}},
  year = {2022},
  eprint = {2211.11138},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2211.11138},
}
Figure