Introduction
Text-to-image diffusion models have revolutionized content creation, yet they often struggle with the ambiguity of natural language when describing complex visual transformations. Tasks like non-rigid artistic distortions or specific structural edits are difficult to capture in a text prompt. RelationAdapter addresses this by enabling Diffusion Transformers (DiTs) to perform "in-context visual learning." By providing a single example pair—a source image and its edited counterpart—the model learns the underlying relation and applies it to a new query image with high fidelity and spatial consistency.
Overcoming the Hurdles of In-Context Learning
Existing methods for visual prompting face significant challenges in extraction, consistency, and efficiency. Traditional approaches often concatenate images in latent space, leading to memory bloat and "feature spillover," where the background of the reference image bleeds into the output. RelationAdapter introduces a lightweight, dual-branch architecture to solve these issues, focusing on learning the "delta" between images rather than just copying appearances.
Methodology
The framework is built upon the FLUX.1-dev architecture and utilizes two core innovations:
1. The RelationAdapter Module
This dual-branch bypass module employs a shared SigLIP vision encoder to extract features from the source and target example images. To prevent the visual prompt from overpowering text instructions, the authors implement Decoupled Attention Injection. This mechanism uses separate Key-Value (KV) projections for visual prompts while sharing the Query (Q) with the main backbone, ensuring the model "observes" the example without losing track of the global context.
2. Positional Encoding Cloning
To maintain spatial consistency, the In-Context Editor uses Positional Encoding Cloning. By explicitly copying positional encodings from the source condition tokens to the noisy target tokens, the model enforces a strict pixel-wise coordinate mapping. This ensures that edits—such as changing a garment's color or adding an accessory—respect the original geometry and identity of the subject.
The Relation252K Dataset
To train a model capable of generalizable editing, the authors developed Relation252K, a massive dataset containing 251,580 training instances across 218 task types. The dataset spans four major domains:
- Low-level processing: Depth estimation, edge detection, and normal mapping.
- Style Transfer: Applying specific artistic styles like Van Gogh or Origami.
- Image Editing: Modifying expressions or adding/removing objects.
- Customized Generation: Complex transformations like "Lego-fication."
Performance and Results
RelationAdapter demonstrates superior performance over baselines like Edit Transfer and VisualCloze. Quantitatively, it achieved a significantly lower Mean Squared Error (0.020 vs 0.043) and higher CLIP-based semantic similarity (0.905 vs 0.827) than Edit Transfer. Qualitative evaluations highlight the model's ability to handle non-rigid transformations without distorting the subject's identity. In human preference studies, RelationAdapter was favored in approximately 70-80% of cases across accuracy and consistency metrics.
Conclusion and Future Directions
RelationAdapter shifts the focus from copying appearances to learning relations. While highly effective, the model still faces challenges with fine-grained text rendering and sensitivity to extremely rare tasks. Future work will explore scaling the architecture to higher resolutions and refining its understanding of nuanced, niche transformations while maintaining the efficiency of the dual-branch approach.
Summary updated