SG-Adapter: Enhancing Text-to-Image Generation with Scene Graph Guidance

## Abstract

Abstract Recent advancements in text-to-image generation have been propelled by the development of diffusion models and multi-modality learning. However, since text is typically represented sequentially in these models, it often falls short in providing accurate contextualization and structural control. So the generated images do not consistently align with human expectations, especially in complex scenarios involving multiple objects and relationships. In this paper, we introduce the Scene Graph Adapter (SG-Adapter), leveraging the structured representation of scene graphs to rectify inaccuracies in the original text embeddings. The SG-Adapter’s explicit and non-fully connected graph representation greatly improves the fully connected, transformer-based text representations. This enhancement is particularly notable in maintaining precise correspondence in scenarios involving multiple relationships. To address the challenges posed by low-quality annotated datasets like Visual Genome [ 1 ] , we have manually curated a highly clean, multi-relational scene graph-image paired dataset MultiRels. Furthermore, we design three metrics derived from GPT-4V [ 2 ] to effectively and thoroughly measure the correspondence between images and scene graphs. Both qualitative and quantitative results validate the efficacy of our approach in controlling the correspondence in multiple relationships.

## 1 Introduction

Image generation has made great progress thanks to the success of a series of text-to-image diffusion models [, , , , , , ]. Due to the huge amount of text-image paired training data[, ] and the numerous model parameters, these text-conditioned models show fantastic image quality and attract great attention from researchers as well as industries.

However, the text encoder used by these models are suboptimal for generating coherent images. They often face challenges in contextualizing text tokens, which requires capturing both their intrinsic meanings and their contextual understanding from surrounding tokens.
The most commonly used text encoder, the CLIP model[], applies causal attention mechanisms to allow tokens to gather information from preceding ones.
However, this sequential processing can lead to the “leakage issue”, where relations or attributes incorrectly influence unrelated elements in the image.
For example, in “A man playing the guitar back to back with a woman”, the relation “playing guitar” might be mistakenly applied to the woman due to the linear text sequence (Fig. 1). Such cases, where the encoder fails to recognize distinct entity boundaries, underscore the need for more advanced text embedding methods capable of accurately depicting separate entities and their respective relations in complex scenes.

Scene graphs, with their structured representation, effectively avoid the contextualization issues inherent in sequential text tokens.
Scene graphs depict images as networks of entities (nodes) and their relationships (edges), ensuring clear, non-linear associations. Relations are directly linked to specific nodes, preventing the ambiguity and misinterpretation common in text-based processing.
This distinct structure allows for precise and unambiguous representation of complex scenes, enhancing the accuracy of image generation.
This capability positions them as a natural control signal for image generation.
However, pure scene graph-to-image generation [, , , ] lags behind text-to-image generation in terms of image quality and is far from practical use. This is because the scene graph-image pair data are considerably smaller than text-image pair data. For instance, Visual Genome[] includes 108,077 pairs with limited-quality scene graph labels. In stark contrast, the typical text-image dataset LAION-5B[] contains a massive 5.85 billion CLIP-filtered image-text pairs.

Figure: Figure 1: Overcoming Contextualization Limits in Image Generation with Scene Graph. The left section highlights the limitations of text embeddings in sequential text processing, showcasing how relations like “playing guitar” may erroneously apply to the “woman”. The right section illustrates the improvements of using a Scene Graph, which provides structured clarity, enabling precise relation.
Refer to caption: x1.png

Acknowledging the challenges in text-to-image generation and scene graph datasets, our research aims to leverage the limited scene graph annotations to enhance the control and accuracy of text-to-image generation.
Recent studies on adapters [, , ], in pre-trained text-to-image models offer promising directions.
These adapters introduce new control mechanisms that retain the model’s image generation quality.

In this study, we re-examine the text-to-image generation process, pinpointing issues of incorrect contextualization arising during text encoder computation.
This problem is traced back to the causal attention mask, which is used in the pre-trained CLIP text model [].
It fails to account for the structural semantics inherent in captions.
However, directly replacing this causal attention mask during inference is ineffective through our observations, as presented in Appendix.A.1.
Consequently, we propose the Scene Graph Adapter (SG-Adapter), strategically plugged in after the CLIP text encoder, to tackle this issue.
This adapter utilizes scene graph knowledge to refine text embeddings.
Critically, to ensure precise contextualization, we design our adapter based on a transformer architecture and incorporate a novel triplet-token attention mask called Scene Graph(SG) Mask, fostering accurate and contextually relevant text-to-image generation.

On the other hand, the quality of scene graph annotations often suffers due to various issues like limited rationality, language biases, or reporting biases.
As a result, many visual relationships in these annotations tend to be simplistic and less informative [].
Traditional datasets are inadequate for experimental observation.
To circumvent these limitations, we conducted preliminary experiments on a smaller-scale but higher-quality dataset Reversion[].
This approach demonstrated the effectiveness of our method.
Subsequently, we expanded our focus to contribute a more complex, multi-relational dataset with highly clean annotations called MultiRels that better encapsulate complex semantic structures.
Our SG-Adapter, finetune on MultiRels, shows a strong ability to generate relations with precise correspondences.
Moreover, considering traditional evaluation metrics like FID and CLIP-Score cannot perceive the abstract Relation Correspondence concept, we propose three evaluation metrics derived from the advanced GPT-4V[] to evaluate the correspondences between images and scene graphs.
In summary, our contributions are as follows:

- •
We propose our SG-Adapter to correct the incorrect contextualization in text embeddings that results in “relation leakage”. Our adapter effectively addresses this issue and enhances the structural semantics generation capabilities of current text-to-image models.
- •
We expand the ReVersion dataset to include multiple relations, creating a more comprehensive dataset with high-quality annotations called MultiRels that could be adopted to better demonstrate the generation models’ ability to handle complex structural semantics. Besides, for effective and fair comparison in terms of relation accuracy, we contribute three metrics derived from GPT-4V[].
- •
Both qualitative and quantitative results illustrate that our SG-Adapter outperforms state-of-the-art text-to-image and SG-to-image methods in terms of relation generation and control.

## 2 Related Work

Text-to-Image Generation. The evolution of text-to-image diffusion models [, , , , , , ] has marked a significant advancement in the generation of high-quality images. Among these, Stable Diffusion (SD) [] is particularly notable, utilizing a pre-trained autoencoder alongside a diffusion model to effectively transform textual prompts into precise and detailed visual representations. Despite their impressive capabilities, these models still face challenges, particularly in terms of the leakage issue, where relations or attributes inadvertently influence unrelated elements within an image [, ]. While [] addresses this through a novel Jensen-Shannon divergence-based binding loss, it does not fully acknowledge the issue as stemming from the improper contextualization of text embedding. In a similar vein, [] employs linguistic structures such as constituency trees or scene graphs to guide the diffusion process. However, this method does not entirely address the root cause of these issues but constructs a set of text embeddings and only partially fixes the wrong contextualization, which is linked to the causal attention mechanism used in the CLIP text encoder.

Scene Graph-to-Image Generation. In the realm of scene graph to image generation, some works often rely on scene layouts as an intermediate representation [, ] in a two-stage pipeline. They first create scene layouts from scene graphs and then generate images based on the layouts. These layouts, serving as image-like representations of scene graphs, can often be suboptimal due to manual crafting and potential misalignment with actual scene graphs. In this paper, we clarify that Layout-to-Image[, , , ] and Scene Graph-to-Image are separate different topics, as demonstrated in Fig.5. Layout-to-Image aims to generate objects in user-specified areas while having limited ability to represent complicated Relations. This limitation has led to the development of alternative approaches, such as SGDiff [], which optimizes scene graph embeddings for better alignment with images, and other works [] that introduce “knowledge consensus” as a means to disentangle complex semantics between knowledge graphs and images. Despite the advances in this field, the dearth of large-scale and high-quality data continues to impede its widespread practical application.

Single Relation Learning. Though Text-to-Image generation models have made great progress, they might fall short when generating complicated single relationships. RRNet[] learns a relationship via a heterogeneous GCN while Reversion[] reverses the target relation from example images by optimizing the relation prompt. Instead of addressing the issue of single relations, our study focuses on generating multiple relations with accurate correspondences.

Adapter. The integration of adapters into existing models has emerged as a noteworthy innovation, exemplified by methods such as ControlNet [] and GLIGEN []. These techniques have enabled models like SD to enhance user control without requiring extensive retraining. For example, ControlNet [] operates as a plug-in module, extracting and integrating residual features from each image condition into SD’s U-Net for enhanced control. GLIGEN [], on the other hand, incorporates location control by integrating a new self-attention module into the U-Net.

Our work critically examines the issue of false contextualization in SD and develops a scene graph-only trained adapter to enhance the semantic structure controllability of SD, addressing a gap in the current landscape of text-to-image generation.

## 3 Proposed Method

In this work, we aim to rectify the incorrect contextualization in text embedding caused by the prevalent causal attention masks in language models, i.e., CLIP text encoder $E_{T}(\cdot)$.

### 3.1 Discussions of Causal Attention

The causal attention mask in the context of transformer models ensures that the prediction for a specific token can only consider previously generated tokens.
For a caption $c$ of $N$ tokens, the causal attention mask $\mathbf{M}$ is an $N\times N$ matrix where each entry $M_{ij}^{\text{causal}}$ is defined as:

$$ $\mathbf{M}_{ij}^{\text{causal}}=\begin{cases}0,&\text{if }j\leq i,\\ -\infty,&\text{if }j>i.\end{cases}$ (1) $$

This matrix is utilized in the scaled dot-product attention mechanism within the transformer model. The attention scores with the mask are computed as follows:

$$ $\text{Attention}(\mathbf{Q},\mathbf{K},\mathbf{V},\mathbf{M})=\text{softmax} \left(\frac{\mathbf{Q}\mathbf{K}^{T}}{\sqrt{d_{k}}}+\mathbf{M}^{\text{}}\right )\mathbf{V},$ (2) $$

where $\mathbf{Q}$, $\mathbf{K}$, and $\mathbf{V}$ denote the query, key, and value matrices respectively, and $d_{k}$ represent the dimension of the key vectors that are used for scaling.
The softmax function is applied subsequent to the addition of the causal attention mask $\mathbf{M}^{\text{causal}}$.
This ensures that for each position $i$ in the sequence, the attention is only on positions $j\leq i$, effectively masking out the future tokens by assigning them a value that approximates zero probability in the softmax due to the $-\infty$ entries in the mask.

However, the causal attention mask may fail to maintain the integrity of subject-relation-object bindings within captions, leading to incorrect contextual associations between entities and relations.
For instance in Fig. 2, the caption “a man holds a cake and a woman holds an apple” contains two distinct subject-relation-object bindings.
However, traditional causal attention will not mask out the former token “holds a cake” when computing the embedding of “a woman” and may incorrectly leak the semantics of “holds a cake” to “a woman”, disrupting the semantic structure of the caption.

To enable precise interactions among tokens, a thorough understanding of the semantic structure encapsulated in the caption is crucial.
This structure is aptly represented by a scene graph, constituted of a sequence of triplets formatted as $\langle\text{subject, relation, object}\rangle$.
The extraction of these $K$ triplets from the caption can be achieved either through an NLP parser [] or GPT-4[].
Each triplet $\mathcal{T}_{k}$ is indexed by $k$, and a token-to-triplet mapping function $\tau(\cdot)$ is defined, which maps each token $i$ to its respective triplet index. The prompt used in GPT-4 is provided in Appendix. A.4.

Our analysis stipulates that interaction between any two tokens $i$ and $j$ is permissible solely when they are constituents of an identical triplet, as determined by the condition $\tau(i)=\tau(j)$.
In light of this, we propose refining the causal attention mask such that it facilitates the alignment of each token with its associated triplet.
This refinement process is intended to bolster the model’s ability to discern and maintain contextual relationships.
The attention mask $\mathbf{M}^{\tau}$, adjusted for triplet alignment, is formally given by:

$$ $\mathbf{M}_{ij}^{\tau}=\begin{cases}0,&\text{if }\tau(i)=\tau(j),\\ -\infty,&\text{otherwise}.\end{cases}$ (3) $$

With the refined attention mask, the most straightforward approach would be to replace the CLIP attention mask during inference.
However, this can cause out-of-distribution issues, as shown in the Appendix. A.1.
Additionally, training a CLIP model from scratch using a scene graph attention mask requires substantial resources.

Figure: Figure 2: Framework for SG-Adapter in Stable Diffusion. The Parser (could be either an NLP tool[] or GPT-4[]) extracts linguistic structures from text inputs. Scene graph embeddings are computed as per Eq (4). The token-triplet matrix, generated by the function $\tau$, guides the refinement of each token and its associated triplet. During testing, when integrated with our SG-Adapter, Stable Diffusion more accurately captures the intended semantic structure in the generated images.
Refer to caption: x2.png

### 3.2 Scene Graph Guided Generation

Scene Graph Representation.
To address these challenges, we devised an alternative approach that augments the text embeddings produced by the CLIP model with the scene graph information.
The text embedding output by the CLIP model is denoted as $\mathbf{w}=E_{T}(c)$, where $\mathbf{w}\in\mathbb{R}^{N\times D}$ and $D$ signifies the dimensionality of the embedding vectors by CLIP Text Encoder $E_{T}$. Here, $\mathbf{w}_{i}\in\mathbb{R}^{D}$ represents the embedding of the $i^{th}$ token.

To encapsulate the scene graph information, we construct a unified embedding for each semantic triplet. For a given triplet $\mathcal{T}_{k}=\langle s_{k},r_{k},o_{k}\rangle$, where $s_{k}$, $r_{k}$, and $o_{k}$ denote the subject, relation, and object of the triplet respectively, we apply $E_{T}$ to each component to obtain their embeddings. These embeddings are then concatenated to form a composite triplet embedding as follows:

$$ $\mathbf{e}_{k}=l(\text{concat}(E_{\text{T}}(s_{k}),E_{\text{T}}(r_{k}),E_{ \text{T}}(o_{k}))),$ (4) $$

where $l(\cdot)$ is a projection function that maps its input to the dimensionality $D$.
The final scene graph embedding $\mathbf{e}\in\mathbb{R}^{K\times D}$ is the concatenation of all the triplet embeddings.
This embedding is then utilized to refine the embeddings of corresponding tokens.

Scene Graph Adapter.
To implement the refinement, an adapter ${f}(\cdot)$ is designed.
Conceptualized as a transformer module, our adapter predominantly integrates a cross-attention layer.
This layer facilitates relation-text attention by leveraging the scene graph embedding $\mathbf{e}$ to calculate the keys $\mathbf{K}$ and values $\mathbf{V}$, and the text embedding $\mathbf{w}$ to calculate the queries $\mathbf{Q}$.
Such interaction is pivotal in updating the text embeddings with relation-specific nuances. The model $f$ is mathematically represented as:

$$ $\displaystyle\mathbf{w}^{\prime}$ $\displaystyle=f(\mathbf{w},\mathbf{e},\mathbf{M})$ (5) $\displaystyle=\text{Attention}(\mathbf{Q},\mathbf{K},\mathbf{V},\mathbf{M}^{ \textbf{sg}}),$ $$

where $\mathbf{Q}=l_{Q}(\mathbf{w})$, $\mathbf{K}=l_{K}(\mathbf{e})$, and $\mathbf{V}=l_{V}(\mathbf{e})$ are derived using respective projection layers in the attention framework. The term $\mathbf{w}^{\prime}$ represents the improved text embeddings resulting from the application of the cross-attention mechanism.

To ensure that each token embedding $\mathbf{w}_{i}$ attends to the appropriate triplet embedding $\mathbf{e}_{\tau(i)}$, we introduce the token-triplet attention mask $\mathbf{M}^{\textbf{sg}}\in\mathbb{R}^{N\times K}$. This mask is designed to allow each token embedding to attend exclusively to its corresponding triplet embedding. The mask is formalized as follows:

$$ $\mathbf{M}_{ik}^{\textbf{sg}}=\begin{cases}0,&\text{if }\tau(i)=k\\ -\infty,&\text{otherwise}\end{cases}$ (6) $$

and implementing this mask within the cross-attention layer of our model permits $\mathbf{w}_{i}$ to be selectively refined based on the contextual relevance of $\mathcal{T}_{\tau(i)}$. Such a targeted approach ensures precise contextualization within the generated scene graph.

To train our model, we leverage the pre-trained diffusion model framework. Given an image $x$, its corresponding text embedding $\mathbf{w}$, and the extracted scene graph embedding $\mathbf{e}$, our model undergoes a training phase analogous to that of the diffusion model. The objective is to minimize the discrepancy between the predicted and actual noise variables. The training loss function is defined as:

$$ $\mathcal{L}_{t}=\mathbb{E}_{\mathbf{x},t,\epsilon}\left[\left\|\epsilon_{t}- \epsilon_{\theta}(\mathbf{x_{t}},t,f(\mathbf{w},\mathbf{e},\mathbf{M}^{sg})) \right\|^{2}_{2}\right],$ (7) $$

where $\epsilon_{t}$ represents the noise variable at time step $t$, and $\epsilon_{\theta}$ denotes the noise prediction from the pre-trained diffusion model parameterized by $\theta$. The function $f(\mathbf{w},\mathbf{e},M)$ encapsulates the adapter’s output, which refines the text embedding with relation-specific context derived from the scene graph embedding.
Our training algorithm iteratively adjusts the parameters of $f(\cdot)$ to reduce $\mathcal{L}_{t}$, thereby improving the fidelity of generated images to the input descriptions and scene graph structure.

## 4 Experiments

### 4.1 Dataset Configuration

As we mentioned above, a scene graph dataset with clean and precise relational annotations is essential as well as effective for learning relation representation.
To train a model that can encode both single and multiple relations accurately, for the first time, we present a multiple relations scene graph-image paired dataset with highly precise labels called MultiRels.
The dataset with size 309 is composed of two parts as follows:

- •
ReVersion []: This part consists of 99 images with only a single clear relation. There are 10 representative relations in Reversion and most of them are “difficult” relations that current text-to-image models can not generate well, e.g., shake hands with, sit back to back, is painted on. Reversion is mainly used to learn new single relations.
- •
Multiple Relations: For multi-relations learning, in this part, we manually collect images with 1-4 (mostly more than 1) salient relations and label them with accurate scene graphs. Most of the relations are “simple” relations (e.g., holding, drinking, stands on, sits on) that current text-to-image models generate well individually but fail when existing multiple objects and multiple relations. There are also small parts of relations that are “difficult” like is above, is under. Multiple Relations is towards to train a model that could generate multiple relations with correct correspondences.

Besides the scene graph, we additionally provide a token-triplet matrix for each image.

Test Scenarios. To fairly validate the effectiveness and generalization performance of our method, we design 20 different testing scenarios that regroup 2-3 randomly selected relations in MultiRels.
For more details about the MultiRels, please refer to our Appendix.

### 4.2 Baseline Methods

Figure: Figure 3: Qualitative Comparisons with Adaptation Methods. In addition to precisely generating each individual relation in the text prompt, our SG-Adapter successfully creates all multiple relations together in correct correspondence.
Refer to caption: x3.png

In our experiments, we evaluate the performance of SG-Adapter against several alternative methods, each with a distinct approach to text-to-image generation:

- •
Fine-tuning (FT): No adapters are used. We directly fine-tune components of Stable Diffusion, CLIP text encoder according to our analysis in Sec.1.
- •
LoRA Adapter: Utilizes the LoRA (Low-Rank Adaptation) adapter []. The LoRA adapter does not integrate direct scene graph information in the adaptation process.
- •
Gated Self-Attention Adapter: Employs the adapter proposed by GLIGEN [] which introduces scene graph tokens into the model. For generating scene graph tokens, we use a specialized scene graph encoder that has been pre-trained for this specific task [].

Note these baseline methods also assess the impact of Scene Graph Embedding from two critical angles:

- •
Inclusion of SG Embed: We explore the necessity of SG Embed by contrasting the performance of our SG-Adapter with the LoRA Adapter, which operates without SG Embed.
- •
Placement of SG Embed: We assess the effect of embedding placement by comparing our model to the GLIGEN Adapter, which integrates SG Embed within a U-Net architecture.

### 4.3 Qualitative Evaluation

We begin with a qualitative assessment, showcasing synthetic images from each method. SG-Adapter’s ability to accurately depict complex relational structures and entities is highlighted, with Fig. 3 illustrating its superiority in maintaining correct relation correspondence in generated images. More qualitative results are provided in our Appendix.

### 4.4 Quantitative Evaluation

**Table 1: Quantitative Evaluation of each method in terms of Automatic Relational Metrics, Human Evaluations, and Image Quality.**
| Method | Automatic Metrics | Human Evaluations | FID $\downarrow$ |  |  |  |
| --- | --- | --- | --- | --- | --- | --- |
| SG- | Entity- | Relation- | Relation- | Entity- |  |  |
| IoU $\uparrow$ | IoU $\uparrow$ | IoU $\uparrow$ | Accuracy $\uparrow$ | Accuracy $\uparrow$ |  |  |
| Stable Diffusion [] | 0.157 | 0.673 | 0.526 | 5.38% | 5.48% | 25.0 |
| Finetune CLIP | 0.198 | 0.499 | 0.635 | 5.38% | 6.78% | 58.2 |
| GLIGEN Adapter [] | 0.141 | 0.689 | 0.546 | 5.72% | 5.58% | 27.4 |
| LoRA Adapter [] | 0.145 | 0.653 | 0.540 | 5.96% | 5.05% | 27.5 |
| SG-Adapter | 0.623 | 0.812 | 0.753 | 77.6% | 77.1% | 26.2 |

Automatic Metrics. Since relation correspondence in images is complicated and abstract, existing metrics like FID can not perceive such conception. To fairly and effectively evaluate the ability to generate accurate relations of each method, we contribute three metrics derived from the advanced GPT-4V[]: Scene Graph(SG)-IoU, Relation-IoU, and Entity-IoU.
These metrics are computed as follows: Given a generated image $I$, we obtain the scene graph represented as a list of triplets:
$\hat{\mathcal{T}}=\{\hat{\mathcal{T}}_{1},\hat{\mathcal{T}}_{2},\ldots,\hat{
\mathcal{T}}_{n}=\langle\hat{s}_{n},\hat{r}_{n},\hat{o}_{n}\rangle\}$
and the entity list $\mathbf{\hat{\xi}}$ using GPT-4V, denoted as $\hat{\mathcal{T}},\hat{\xi}=\mathrm{GPT}(I)$.The extraction prompt is provided in the appendix, see A.4. From $\hat{\mathcal{T}}$, we can also derive the relation list $\mathbf{\hat{r}}$. Then, given the input scene graph $\mathcal{T}$ and entity list $\mathbf{\xi}$ derived from $\mathcal{T}$, the three metrics are computed as follows:

$$ $\mathrm{SG\text{-}IoU}=\mathrm{IoU}(\mathcal{T},\hat{\mathcal{T}}),\quad \mathrm{Entity\text{-}IoU}=\mathrm{IoU}(\xi,\hat{\xi}),\quad\mathrm{Relation \text{-}IoU}=\mathrm{IoU}(\mathbf{r},\mathbf{\hat{r}})$ $$

SG-IoU indicates whether each relationship is well generated according to input correspondence and the other two metrics show whether each object and relation are generated.

Human Evalution.
We conduct a user study engaging 104 participants in evaluating 20 test scenarios, each comprising textual descriptions and corresponding sets of images from the evaluated methods. We collect the percentage of user preference for each method in terms of the following criteria:

Entity Accuracy: Evaluating the precision in representing all textual entities within the images.

Relation Accuracy: Assessing the accuracy of depicted relationships between entities, ensuring alignment with the textual descriptions.

Image Quality. We compute the FID[] which quantifies the discrepancy between the distribution of generated images and 5000 validation images from the MS-COCO-Stuff[].

Quantitative Analysis.

- •
Relation Correctness. As demonstrated in Tab. 1, SG-Adapter consistently outperforms the baseline methods on both Automatic Metrics and Human Evaluations, significantly on SG-IoU and Relation Accuracy, showing a strong ability to generate relations with precise correspondences. Besides, high Entity-IoU and Relation-IoU while low SG-IoU indicate that though all the baseline methods successfully generated the required entity and relation, they can not distribute them to each other with correct correspondence.
- •
Image Quality Maintenance. Finetuning a pre-trained T2I model on a relatively small dataset will degrade the FID inevitably[, ]. As presented in Tab.1, our SG-Adapter maintains the image quality best among all the alternatives.

### 4.5 Ablation Study

**Table 2: Ablation study on SG Mask.**
| Method | SG-IoU $\uparrow$ | Entity-IoU $\uparrow$ | Relation-IoU $\uparrow$ | FID $\downarrow$ |
| --- | --- | --- | --- | --- |
| w/o SG Mask | 0.316 | 0.742 | 0.668 | 26.7 |
| SG-Adapter | 0.623 | 0.812 | 0.753 | 26.1 |

To elucidate the contributions of SG-Adapter’s distinct components, we performed a comparative analysis by systematically ablating specific features. Through our experiments, we have demonstrated that the inclusion of scene graph embeddings is essential and that integrating them into the text encoder is more effective. In this section, we conduct an ablation study on the internal elements of our method:

Token-to-Triplet Causal Mask (SG Mask): We assessed the significance of the causal mask designed to map tokens to triplets, evaluating its role in refining the image generation process.

As shown in Tab. 2, our method performs better than the one without SG mask on all evaluation metrics, indicating the effectiveness of the proposed SG mask.

### 4.6 SG-to-Image Generation Evaluation

We further benchmark our method against state-of-the-art SG-to-Image generation approaches including SG2IM[], PasteGAN[], SceneGenie[] and SGDiff[] both quantitatively and qualitatively. (Note that SceneGenie does not release the code, we just report the quantitative result from their paper.)
We train our SG-Adapter on the commonly used Scene Graph dataset [] to demonstrate that our method is extendable to large-scale datasets. For Flickr30k [], we employed NLP processing techniques[] to extract scene graph information.

For qualitative comparison, we present generated images of each method in Fig. 4.
Benefiting from our learned adapter strategy, we harness the high-resolution and high-fidelity generative capabilities of pre-trained text-to-image models, thereby achieving superior image quality in our results. Moreover, our method adeptly renders complex relational structures in images, signifying that our adapter effectively leverages scene graph information to accurately reflect intricate relationships within the visual output.

For quantitative comparison, due to the large size of the validation sets in the above datasets, performing GPT-4V-based evaluations for all methods would require a significant number of API calls, exceeding our available resources.
Therefore, we primarily evaluated image quality metrics.
We provided the FID and Inception Score [] for each method in Tab. 3.
The results were also tested on the COCO-Stuff validation dataset with a resolution of 256$\times$256. Tab. 3 shows that SG-Adapters outperform other SG-to-Image approaches on both evaluation metrics by a significant margin, demonstrating superiority in both image fidelity and diversity.

**Table 3: Comparison with SG2I Generation Methods.**
| Method | SG2IM [] | PasteGAN [] | SGDiff [] | SceneGenie [] | SG-Adapter |
| --- | --- | --- | --- | --- | --- |
| FID $\downarrow$ | 99.1 | 79.1 | 36.2 | 62.4 | 25.1 |
| Inception Score $\uparrow$ | 8.2 | 12.3 | 17.8 | 21.5 | 57.8 |

Figure: Figure 4: Comparison with Scene Graph to Image Generation. SG-Adapter outperforms other SG generation methods in terms of image quality and relation accuracy.
Refer to caption: x4.png

Figure: Figure 5: Left: The same layout appears visually different due to different relationships. Right: Our method is also capable of learning the customized single relationship.
Refer to caption: x5.png

## 5 Conclusion and Discussion

This paper introduces the Scene Graph Adapter (SG-Adapter), a novel enhancement for text-to-image generation models. By integrating scene graph knowledge, the SG-Adapter significantly improves the contextual understanding of these models, ensuring images closely match their textual descriptions. The adapter employs an efficient triplet-token attention mechanism within a transformer architecture, allowing for more precise mapping of text to visual elements. To validate its effectiveness, the study utilized a specially curated dataset featuring multiple relations and high-quality annotations, showing the crucial role of clean, relation-rich data in multi-relational learning. As shown in Fig.5, SG-Adapter can also learn single complex relations as a by-product. Furthermore, we propose three effective metrics derived from GPT-4V[] to evaluate the generated relation precisely. Lastly, our method could learn a new and complex single relation as a by-product, similar to ReVersion[] and RRNet[], as demonstrated in Fig.5.

As for limitation, to address data privacy concerns and follow the double-blind policy, we applied anonymization techniques to human faces in our MultiRels dataset, which may introduce some artifacts affecting image quality inevitably. We are actively exploring more sophisticated anonymization methods that preserve data integrity while ensuring privacy.

## Appendix A Appendix

### A.1 Initial Experiment with Scene Graph Attention Mask

Figure: Figure 6: Results of Initial Attempt and SG-Adapter. Directly integrating the structural token-token attention mask in a hard way within the CLIP model could break the delicate balance of learned sequential dependencies and fail to ensure accurate semantic structure in the generated images. Instead, our SG-Adapter makes use of a novel token-triplet attention mask in a learnable way to correct the unreasonable token-token interactions and guarantee precise relation correspondence.
Refer to caption: x6.png

Our initial attempts involved the utilization of an adjusted attention mask $\mathbf{M}^{\tau}$ within the transformer’s attention mechanism of the CLIP text encoder, aiming to ensure intra-triplet attention cohesion and maintain the semantic structure of caption.
This integration, however, did not translate to empirical improvements as shown in Fig. 6.
We observed that directly manipulating the attention mask of the pre-trained CLIP model could disrupt the delicate balance of learned sequential dependencies, adversely affecting the quality of text-to-image synthesis due to inconsistencies between the model’s training and inference methodologies.

### A.2 MultiRels Benchmark Details

As mentioned in the main paper, we organized the MultiRels into two parts: Reversion and Multiple Relations. This section will introduce more detailed information about the Multiple Relations part.

The Multiple Relations part contains 210 samples. We initially plan to collect all the images from the Internet and then label them manually. However, after we had collected dozens of images, we found this way not efficient enough since there are very few images that contain multiple clear and salient relations. Besides, a text describing a multiple relations image tends to be long so the relevance of retrieved images will also decrease with the longer text. Therefore we only collect 40 multi-relations images from the Internet by retrieving a long text.

On the contrary, 170 images in the Multiple Relations part were taken by ourselves.

- 1.
Concerning human relations, we mainly focus on “holding", “drinking", “stands on", “sits on" such kinds of simple human actions, combining random 2-3 relations from them to result in 15 different text templates containing multiple relations finally. To make the collected images as diverse as possible, we arranged for 5 volunteers to participate in the photoshoot in 6 different environmental backgrounds both indoor and outdoor. We re-paint faces in these photos locally for the privacy of the volunteers and the blind paper review. We examples of the above data in Fig.7, Fig.8.
- 2.
For object relations, we consider the positional relationships like “is above", and “is under". We place various normal objects, e.g. fruits and daily necessities, on the same/different side of an object like a table, chair, bench, and so on. Also, for the diversity of the data set, we take photos of these objects in 6 different indoor and outdoor environments. There are examples provided in Fig.9, Fig.10.

The 15 templates we adopt in human relations are as follows:

- 1.
a man stands on floor and a woman sits on a chair.
- 2.
a woman stands on floor and a man sits on a chair.
- 3.
a man stands on floor and a woman stands on floor.
- 4.
a man sits on a chair and a woman sits on a chair.
- 5.
a man drinking milk and a woman drinking cola.
- 6.
a man sits on a chair and a woman holding a $\langle obj\rangle$ stands on floor.
- 7.
a woman sits on a chair and a man holding a $\langle obj\rangle$ stands on floor.
- 8.
a man drinking juice sits on a chair and a woman stands on floor.
- 9.
a man holding a $\langle obj\rangle$ stands on floor and a woman drinking water stands on floor.
- 10.
a man stands on floor and a man sits on a chair.
- 11.
a man drinking water sits on a chair and a man holding a $\langle obj\rangle$ stands on floor.
- 12.
a man holding a $\langle obj\rangle$ stands on floor and a man sits on a chair.
- 13.
a man holding a $\langle obj\rangle$ stands on floor and a man stands on floor.
- 14.
a man drinking juice and a man drinking water.
- 15.
a man drinking water and a man drinking water.

To see the complete data set and its corresponding metadata, please refer to the compressed file MultiRels.zip.

### A.3 Additional Qualitative Results

We present additional qualitative results of our SG-Adapter compared with other baseline methods in Fig.11, Fig.12.

### A.4 GPT-4V Prompts

Prompt to Extract Scene Graph from Image: Please extract the scene graph of the given image. The scene graph just needs to include the relations of the salient objects and exclude the background. The scene graph should be a list of triplets like ["subject", "predicate", "object"].
Both subject and object should be selected from the following list: ["an astronaut", "a ball", "a cake", "a box", "a television", "a table", "a horse", "a pitaya", "a woman", "a book", "a laptop", "a bottle", "a banana", "a sofa", "floor", "water", "an apple", "a chair", "a pineapple", "an umbrella", "a boy", "a paper", "a bear", "a girl", "a panda", "a cup", "a man", "a bike", "a carrot", "a phone"].
The predicate should be selected from the following list: ["stands on", "is above", "drinking", "is under", "sits back to back with", "ride on", "holding", "sits on"]
Besides the scene graph, please also output the objects list in the image like ["object1", "object2", …, "object"]. The object should be also selected from the above-mentioned object list. The output should only contain the scene graph and the object list.

Prompt to Parse Caption to Scene Graph:Here I have a group of captions and please help me to parse each one. Each caption should be transformed to a Scene Graph reasonably which is composed of some relations. A relation is a triplet like [subject, predicate, object] and please replace the original pronouns with reasonable nouns. Both subject and object should only have one object or person. "and" relation should not be included in the Scene Graph. Besides, I want to get the indexes of all of the subjects, predicates, and objects in the original caption, which is called mapping here.
For example, the caption is: a boy holding a bottle shakes hands with a girl sitting on a bench.
The corresponding Scene Graph should be: [[a boy, holding, a bottle], [a boy, shakes hands with, a girl], [a girl, sitting on, a bench]].
The indexes of each word(punctuation is also considered a word) in the caption(called all_words_indexes) are:"a":0, "boy":1, "holding":2, "a" :3, "bottle":4, "shakes":5, "hands":6, "with":7, "a":8, "girl":9, "sitting":10, "on":11, "a":12, "bench":13.
The index of every word in the Scene Graph(i.e., the mapping) should be:["a":0, "boy":1, "holding":2," a":3, "bottle":4,"a":0, "boy":1, "shakes":5, "hands":6, "with":7, "a":8, "girl":9, "sitting":10, "on": 11,"a":12, "bench":13]
The indexes of all of the subject, predicate, and object in the original caption should be highly precise. The results of each caption are data like:
scene graph:
all_words_indexes:
mapping:
When generating the mapping please refer to the scene graph and the all_words_indexes to ensure the correct result.
The captions are:

### A.5 Implementation Details

All the experiments are conducted on $768\times 768$ image resolution and all the models are trained on a single A100 GPU for several hours. We adopt SD 2.1 as our base model. We set training batch size 4, learning rate 1e-5. We adopt the optimizer AdamW and most models converge around 12000 to 14000 iterations. During the sampling process, we use a parameter $\tau$ to balance the ability to control and the image quality. For a diffusion process with $T$ steps, we could use scene graph guided inference at the first $\tau*T$ steps and use the standard inference for the remaining $(1-\tau)*T$ steps. In this paper, $\tau$ set to 0.3 is enough to achieve relation control while maintaining the image quality.

Figure: Figure 7: Example 1 of MultiRels
Refer to caption: x7.png

Figure: Figure 8: Example 2 of MultiRels
Refer to caption: x8.png

Figure: Figure 9: Example 3 of MultiRels
Refer to caption: x9.png

Figure: Figure 10: Example 4 of MultiRels
Refer to caption: x10.png

Figure: Figure 11: More qualitative results-1.
Refer to caption: x11.png

Figure: Figure 12: More qualitative results-2.
Refer to caption: x12.png

## Peer Reviews

confidence: 4
contribution: 3
initial_rating: 6
presentation: 1
questions: 1. L40 missing space between "CLIP model" and the citation.
2. The $\mathbf{M}^{\tau}$ in Eq. 3 can be named differently, e.g. triplet-triplet mask, to distinguish it apart from the token-triplet attention mask in Eq. 5.
3. For Fig. 2, I suggest putting some of the introduced notations in Fig. 2 to help the reader understand the paper, e.g. model $f$, embedding $\mathbf{e}, \mathbf{w}$, etc. Fig. 2 can also be improved by using more arrows between features or modules to make it more concise and clear. For example, the inputs and outputs on the right side of the figure should be indicated with arrows. Redundant word in L233 Eq (equation) 4. The visualization of the matrix and the given scene graph example do not match. There are 2 triplets with 6 tokens in the input scene graph. I think it is a good opportunity to show what is $\mathbf{M}^{sg}$ and $\mathbf{M}^{\tau}$ for the inputs here.
4. L267, $\mathbf{M}$ or $M$? 
5. In Eq. 5, what is the difference between $\mathbf{M}^{sg}$ or $M$?
5. I am confused about Tab. 2 and L413, is it about $\mathbf{M}^{\tau}$ or token-triplrt mask $\mathbf{M}^{sg}$. I thought $\mathbf{M}^{\tau}$ is for solving the problem of causal masks.
6. Fig. 1, I assume the add signs mean StableDiffusion + SGAdapter and Caption + Scene graphs. I think it can made clearer as initially I was not sure whether you were replacing captions with scene graphs or using both.
soundness: 3
strengths: 1. The method is simple and straightforward in solving the identified problem.
2. The empirical improvement is significant.
summary: This paper proposes SGAdapter which solves the problem of using sequential representations for input text in recent text-to-image generation methods. They augment their approach with scene-graph-to-image generation due to the graph representations. SGAdapter introduces a small-scale adapter between StableDiffusion and the CLIP encoder for this task. They also identify the problem of casual attention masks for scene graphs. They curate a new dataset for scene-graph-to-image generation. The experiments show that SGAdapter can generate realistic images from more complicated input sentences than baselines.
weaknesses: 1. Some figures are not clear.
2. Some confusing notations.

---

confidence: 4
contribution: 3
initial_rating: 6
presentation: 4
questions: Can SG-Adapter solves the color bind problems?
soundness: 3
strengths: a. The proposed SG-adapter is effective in correcting the incorrect contextualization in text embeddings and enhancing the structural
semantics generation capabilities of current text-to-image models.

b. Both qualitative and quantitative experiments demonstrate SG-Adapter outperforms compared SOTA methods.
summary: To correctly align text-image consistency for text-to-image task, especially in complex scenarios involving multiple objects and relationships, this paper proposes SG-Adapter to leverage the structured representation of scene graphs to rectify inaccuracies in the original text embeddings. A highly clean, multi-relational scene graph-image paired dataset MultiRels is constructed to address the challenges posed by low-quality annotated datasets. Qualitative and quantitative experiments validate the efficacy of the proposed method in controlling the correspondence in multiple relationships.
weaknesses: a. The format of citations in this paper need be rectified.

b. This method requires the construction of a high-quality dataset, and it is mainly effective for the relationships within the constructed dataset, which will limit its generalization ability.

c. The quantitative results are insufficient and the author should provide more results to prove the its effectiveness.

---

confidence: 4
contribution: 2
initial_rating: 5
presentation: 3
questions: -  The currently shown results (Figure 3) seem to have at most two main bodies interacting with their accessories. 1) In the case of more main bodies, such as a crowd surrounding or three people facing away from each other; 2) For some pairs that may not be common in the training set, such as pandas riding on horsebacks, what is the generation effect like? This helps evaluate whether the sg-adapter has learned to generate general interaction relationships or just high-frequency combinations in the training set.
 - The effect of scene graph detection may not be 100% accurate. What will be the effect when the detection result conflicts with the meaning of the text itself? Will it be more serious for some freely input long texts? For example, when users use the text-to-image function, they often add a long string of magic prompts, such as 4K, realistic, specific lenses, etc. These may all have an impact on scene graph detection.
 - How many parameters need to be fine-tuned in the current adapter part? Will the size of the number of parameters affect the final effect? The analysis of this part may make the article more complete.

In general, I think the problem solved by this paper is quite important. However, I feel that the current method is not general enough and may be a temporary technique. When there is a specific need for interaction generation in a specific scene, fine-tuning based on the SG Adapter will have some improvement. But it does not fundamentally solve the problem of entity interaction. Because I think the introduction of the SG adapter will lead to the problem that entity interaction adds the long-tail problem of scene graph detection on top of the long-tail problem of interaction relationships in the training set itself. The impact on the community may be limited. If the author has more thoughts and ideas on this aspect, we can discuss them.
soundness: 3
strengths: - The motivation is straightforward. The description of the problem and method is simple, clear and understandable.
 - Entity interaction information is introduced through scene graph to optimize the generation of entity interaction, which is relatively direct.
 - Judging from the demo and numerical comparison results, there are good results.
summary: This paper hopes to optimize the generation of entity interaction in text-to-image generation by introducing the scene graph structure into the adapter. The method is simple and clear and has achieved significant improvement compared to the baseline.
weaknesses: - The novelty in method design is limited. It only performs an attention on the text embedding based on the scene graph relationship. It can even be considered as a replacement of the key and value values in the cross attention structure. Simplicity is not a disadvantage. If it is simple, direct and works, the author can provide some discussions to analyze the most important factors behind it.
Is the adapter structure important or is the scene graph information the most important? For example, in addition to the adapter, can simply injecting scene graph information through cross attention also obtain similar results?
And whether there are some situations where scene graph information is not applicable.
 - The experimental evaluation of entity interaction generation is not comprehensive enough. The scene graph detection method itself will also have a very obvious long-tail phenomenon for entity relationships. For entity interaction image generation, this should also be considered. Distinguishing and explaining according to the detection frequency in the training dataset will make the evaluation of the model more comprehensive and convincing. The author can try to divide buckets according to the frequency of scene graph detection, and finally give the results of each bucket and the average result.

---

confidence: 4
contribution: 2
initial_rating: 5
presentation: 2
questions: See the detail in the weaknesses
soundness: 3
strengths: 1. The paper contributes a scene graph dataset with relational annotations, which adds value to the community.
2. The authors include their code in the supplemental materials.
3. Human evaluations are conducted to assess the effectiveness of the proposed method.
summary: This paper presents a Scene Graph Adapter for text-to-image generation that leverages scene graph to refine CLIP text embeddings. Additionally, a dataset of 309 images with relational annotations is proposed for evaluation.
weaknesses: 1. Experiments are conducted only on the proposed dataset, which is relatively small and may not provide a robust evaluation.
2. The method uses a Scene Graph to refine CLIP text embeddings, which may be overly simplistic. I think the adapter should also change the parameters of the Stable Diffusion.
3. The latest method compared in Table 1 is from 2023. Including more recent methods would strengthen the comparative analysis.
4. The authors note that fine-tuning Stable Diffusion on a small dataset can degrade FID (shown in Table 1). Fine-tuning on a larger dataset, such as Flickr30k Scene Graph, is recommended.
5. Human evaluation is conducted on only 20 cases (from the proposed test set). Expanding the test set could improve the reliability of these results.

Meta-review: While both R1 and R2 viewed the paper marginally above the acceptance threshold (based on the simpleness and effectiveness of the method in correcting the incorrect contextualization in text embeddings and enhancing the structural semantics generation capabilities), they shared concerns about poor presentation (i.e., unclear figures, confusing notation, and citation format). R2 also questioned the need for high-quality datasets and asked for more quantitative results (which are addressed by the authors).  R3 and R4 leaned toward rejection of the paper due to its limited novelty, insufficient experimental evaluation, and narrow generalization. With the introduction of SG-Adapter and a new dataset, the method is considered incremental and overly simplistic, failing to provide a fundamental advancement in the field. While the authors responded to both R3 and R4 in addressing the above concerns, both reviewers read the responses and decided marginally below the acceptance threshold. Weighing all the factors and the review quality, I tend to agree with R3 and R4 and rate the paper marginally below the acceptance threshold.

Decision: Reject