Reference-based Image Composition with Sketch via Structure-aware Diffusion Model

Kangyeol Kim, Sunghyun Park, Junsoo Lee, Jaegul ChooarXiv 2023 · DOI

TL;DR

This research introduces a novel image composition framework that utilizes a structure-aware diffusion model to edit images using two simultaneous inputs: a hand-drawn sketch and a reference image. By combining structural guidance with semantic content, the model enables precise, fine-grained control over image editing, allowing users to modify an object's shape and appearance with unprecedented accuracy.

Introduction

While large-scale text-to-image models have transformed AI-driven content creation, they often lack the precision required for specific editing tasks. Textual descriptions are frequently too ambiguous to define exact shapes or intricate patterns. Existing image-conditioned models, such as Paint-by-Example, allow for reference-based inpainting but fail to provide "edge-level controllability." To address this gap, the authors propose a dual-conditioning approach that uses sketches to dictate structure and reference images to provide semantic style.

Methodology

The framework is built upon Latent Diffusion Models (LDM) and incorporates several key technical innovations:

  • Multi-Input Conditioning: The model processes four distinct inputs: the original image with a masked area, the binary mask, a structural sketch, and a semantic reference image.
  • Smart Initialization: To ensure stability and faster convergence, the model is initialized with weights from Paint-by-Example. This leverages pre-existing knowledge of reference-based inpainting, bypassing the "cold start" problem of balancing two different guidance modalities.
  • Sketch Plug-and-Drop Strategy: To prevent unrealistic artifacts from overly simplistic user sketches, this strategy selectively relaxes sketch guidance during specific diffusion steps. This allows the model to generate natural textures while respecting the general boundaries defined by the user.
  • Conditioning Pipeline: Semantic information from the reference image is extracted via a CLIP encoder and an MLP, while the sketch and masked image are directly integrated into the U-Net architecture.
Overview of the proposed framework demonstrating image editing through varying references (left) and structural sketches (right).

Experimental Setup

The model was trained and evaluated using the following resources:

  • Danbooru Dataset: A large-scale anime dataset provided 55,104 training pairs and 13,775 test pairs.
  • Real-world Scenes: Testing extended to "in-the-wild" examples from Naver Webtoon and Studio Ghibli films to verify cross-domain robustness.
  • Edge Extraction: Training sketches were automatically generated using Pixel Difference Networks (PiDiNet) to simulate user-drawn inputs.

Results and Discussion

The proposed model, Paint-by-E+S (Example + Sketch), demonstrates superior performance over existing baselines in both quantitative and qualitative assessments.

Quantitative Performance

The model achieved a Fréchet Inception Distance (FID) of 5.716, significantly lower than the 6.314 recorded for the standard Paint-by-Example model. Lower FID scores indicate higher visual realism and better alignment with the target distribution. Additionally, the model showed reduced $L_1$ and $L_2$ reconstruction errors.

Qualitative Analysis

Qualitative results highlight the model's ability to handle complex structural modifications. For instance, it can accurately adjust a character's pose based on a sketch or integrate new architectural elements into a landscape while preserving the original artistic style. A notable discovery was the "Self-Reference Generation" capability, where parts of the original image serve as the reference, ensuring perfect stylistic and lighting consistency across the edit.

Conclusion

This work successfully bridges the gap between semantic reference and structural control in image composition. While the current implementation requires pre-drawn sketches, the "Plug-and-Drop" strategy effectively balances user intent with generative realism. Future work aims to develop real-time interactive interfaces, paving the way for more intuitive and powerful AI-assisted artistic workflows.

Summary updated

BibTeX
@misc{kim2023reference,
  author = {Kangyeol Kim and Sunghyun Park and Junsoo Lee and Jaegul Choo},
  title = {{Reference-based Image Composition with Sketch via Structure-aware Diffusion Model}},
  year = {2023},
  eprint = {2304.09748},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2304.09748},
}
Figure