Abstract
Despite their exceptional generative abilities, large text-to-image (T2I) diffusion models often struggle with accurately depicting visual relationships between objects. This issue arises from a misaligned text encoder that fails to interpret specific relationships and differentiate the logical order of associated objects. We introduce Relation Rectification, a task aimed at refining models to accurately represent relationships they initially fail to generate. Our solution, RRNet, utilizes a Heterogeneous Graph Convolutional Network (HGCN) to model directional relationships between objects and relation terms. By adjusting the text embeddings (specifically the [EOT] token) while keeping the base model frozen, RRNet ensures accurate relational representation without sacrificing general performance. We validate our approach on a new dataset, demonstrating significant qualitative and quantitative improvements.
Introduction
Current text-to-image diffusion models often suffer from "relational blindness," failing to distinguish between compositional structures such as "a cat on a mat" and "a mat on a cat." Despite their artistic capabilities, models like Stable Diffusion (SD) frequently treat prompts as a "bag of words," ignoring the logical order of objects.
Technical analysis reveals that the root cause lies in the text encoder (CLIP). For "Object-Swapped Prompts" (OSPs)—pairs like "A inside B" and "B inside A"—the resulting text embeddings are nearly identical. Crucially, the [EOT] (End of Text) token, which serves as a global summary of the prompt, fails to capture the directionality of the relationship. Since the diffusion model relies heavily on this [EOT] embedding to layout the scene, the final image often fails to reflect the intended relational logic.
Methodology: Relation Rectification (RRNet)
To address these shortcomings, we propose Relation Rectification (RRNet), a framework designed to nudge text embeddings into the correct "relational neighborhood" before they reach the diffusion model.
The core of RRNet is a Heterogeneous Graph Convolutional Network (HGCN). Relationships are represented as directed graphs (e.g., Object A -> Relation R -> Object B), allowing the model to explicitly capture directionality. The HGCN processes these graphs, taking initial word embeddings from CLIP and producing an adjustment vector ($\Delta[EOT]$). This vector is added to the original [EOT] embedding. A scaling factor ($\lambda$) allows users to control the strength of the rectification, balancing relational accuracy against original image quality.
RRNet is trained using a dual-loss strategy on a small set of reference images:
- Positive Loss: Standard denoising to match the target image.
- Negative Loss: Ensures the embedding for "A on B" is pushed away from the image of "B on A," effectively separating OSPs in the latent space.
Experimental Results
We evaluated RRNet on a new Relation Rectification Benchmark featuring 21 distinct relationships (8 positional and 13 action types) and 4,200 generated images.
Key Findings
- Accuracy and Preference: RRNet improved relationship generation accuracy by up to 25% over vanilla Stable Diffusion. In a user study, RRNet-generated images were preferred 75.56% of the time. Quantitative evaluation using VLM-based evaluators (Qwen-VL and LLaVA) showed RRNet outperformed methods like Textual Inversion and DreamBooth.
- The [EOT] Anchor: Our analysis confirmed that the [EOT] token acts as a global layout controller. Masking it destroys relational semantics, whereas masking individual words has a significantly smaller impact.
- Zero-Shot Generalization: Once trained on a specific relationship (e.g., "A inside B"), RRNet generalizes to unseen objects. For instance, learning "cloth inside bowl" allows the model to successfully generate "panda inside car" without further training.
- Efficiency: Training the lightweight HGCN for a specific relationship takes approximately 20 minutes on a single NVIDIA V100 GPU.
Conclusion and Future Work
RRNet provides a lightweight and effective solution for rectifying relational errors in diffusion models without retraining the entire backbone. However, limitations remain. The model cannot force the generation of concepts the base diffusion model has never seen (e.g., "a horse riding an astronaut"). Additionally, performance can degrade when handling multiple complex relationships simultaneously. Future research will explore more complex graph structures to jointly rectify multiple relational semantics within a single adjustment vector.
Summary updated