LayerDiffusion: Layered Controlled Image Editing with Diffusion Models

Pengzhi Li, Qinxuan Huang, Yikang Ding, Zhiheng Li

TL;DR

LayerDiffusion is a novel framework that enables simultaneous, high-fidelity editing of both foreground subjects and backgrounds in a single image using diffusion models. By treating the subject and background as distinct semantic layers, it allows for complex non-rigid changes—like making a sitting dog jump in a new forest setting—while strictly preserving the unique identity of the original subject.

What Problem Does This Paper Address?

While large-scale text-to-image models like Stable Diffusion are incredibly powerful, they struggle with "identity-preserving" edits. If you ask a standard model to turn a photo of your specific pet into a photo of that pet jumping on a beach, the model often generates a generic animal that looks nothing like yours.

Current state-of-the-art methods face a "trilemma":

  1. Rigid Editing: They can change colors or styles but fail at non-rigid transformations (changing poses or actions).
  2. Identity Loss: They lose the specific characteristics of the subject when the background changes.
  3. Input Overhead: They often require extra data, like multiple reference photos or manual sketches/depth maps.

LayerDiffusion aims to solve these by allowing "layered" control, enabling users to perform multiple editing actions (e.g., "change pose" + "change background") using only a single input image and a text prompt.

Methods

The authors propose a three-stage pipeline to achieve this layered control:

  1. Layered Controlled Optimization: The system first uses the Segment Anything Model (SAM) to generate a mask. It then decomposes the target text prompt into foreground and background descriptions. It optimizes two separate text embeddings ($e_a$ for the object and $e_b$ for the background) to match the input image. These are eventually blended into an optimized embedding ($e_{opt}$) via linear interpolation.
  2. Layered Diffusion Training (Fine-tuning): To ensure the model truly understands the specific subject and background, the researchers fine-tune the diffusion model's weights. They use a dual-loss function ($\mathcal{L}_{obj}$ and $\mathcal{L}_{bg}$) that forces the model to reconstruct the foreground and background independently, preventing the "bleeding" of features between the two.
  3. Iterative Guidance Strategy: During the final image generation (inference), the model doesn't just use one prompt. It iteratively alternates between the specific object embedding and the blended embedding. This acts as a strong constraint, ensuring the model prioritizes the requested action (like "jumping") without forgetting what the original object looked like.

Datasets

  • Pre-training: The method builds upon Stable Diffusion v1.4, which was trained on the massive LAION-5B dataset.
  • Evaluation: The authors utilized the TEdBench (Text-based Editing Benchmark) to compare their results against other models.
  • Custom Testing: They generated a diverse set of over 300 images across various domains (animals, buildings, objects) to test the robustness of the multi-task editing.

Key Insights and Ideas

  • Divide and Conquer: The "aha moment" here is that background and foreground features often compete for the model's attention. By optimizing and training them as separate semantic layers, the model can modify one without "corrupting" the other.
  • Action vs. Identity: The iterative guidance strategy is a clever way to bypass the "network bias" where a model prefers the static pose of the original image. By periodically "reminding" the model of the foreground object's specific properties during denoising, it can successfully execute complex actions like running or flying.
  • Single-Image Power: Unlike methods like DreamBooth, which require 3-5 images of a subject, LayerDiffusion achieves high identity preservation with just one reference image.

Key Results

  • Quantitative: LayerDiffusion achieved a CLIP score of 0.35, significantly outperforming other leading methods like SDEdit (0.28), PnP (0.32), and Imagic (0.29). This indicates much better alignment between the generated image and the text prompt.
  • Qualitative: The paper showcases impressive results where subjects (lions, bears, dogs) are moved from their original contexts into entirely new environments with completely different poses (e.g., a sitting teddy bear transformed into one playing soccer in a bedroom).
  • User Study: In a study with 20 participants, LayerDiffusion's results were consistently rated higher for both background similarity and action accuracy compared to competing frameworks.

Limitations and Future Work

Despite its success, the authors note a few hurdles:

  • Fine-Grained Details: The model still struggles with extremely intricate textures or human facial features, which can sometimes result in artifacts.
  • Camera Angles: If there is a massive disparity between the camera angle of the reference image and the requested scene, the resulting image can look visually inconsistent.
  • Compute Time: The process requires per-image fine-tuning, which takes approximately 2 minutes on an NVIDIA A100 GPU. While fast for research, it's not yet "instant" for consumer applications.
  • Future Direction: The team plans to focus on better preservation of complex textures and improving the rendering of human faces in future iterations.

Summary updated

BibTeX
@inproceedings{li2023layerdiffusion,
  author = {Pengzhi Li and Qinxuan Huang and Yikang Ding and Zhiheng Li},
  title = {{LayerDiffusion: Layered Controlled Image Editing with Diffusion Models}},
  booktitle = {SIGGRAPH Asia Technical Communications},
  year = {2023},
  url = {https://openreview.net/forum?id=fE-nZDZ1y6},
}

Loading related content...

Figure