PrimeComposer: Faster Progressively Combined Diffusion for Image Composition with Attention Steering

Yibin Wang, Weizhong Zhang, Jianwei Zheng, Cheng Jin

Image composition—the seamless integration of a foreground object into a new background—remains a significant challenge in computer vision. While diffusion models have revolutionized image generation, adapting them for precise, training-free composition often results in a trade-off between visual coherence, identity preservation, and computational speed. PrimeComposer addresses these challenges by reformulating composition as a subject-guided local editing task, utilizing a novel "attention steering" mechanism to achieve state-of-the-art results with nearly double the efficiency of previous methods.

Addressing the Bottlenecks of Image Composition

Existing training-free methods for image composition typically struggle with three primary issues:

  1. Coherence Confusion: The added object often fails to match the lighting, texture, or artistic style of the background, leading to a "cut-and-paste" appearance.
  2. Appearance Loss: The subject often loses its unique identity (e.g., a specific pet starts looking like a generic version of that species) during the diffusion process.
  3. Efficiency Constraints: Previous state-of-the-art frameworks, such as TF-ICON, require multiple complex sampling passes, making them computationally expensive and slow for practical use.

PrimeComposer identifies that these problems stem from attempting to regenerate the entire scene or using conflicting attention weights from different contexts. By shifting the paradigm toward local editing, the framework avoids these pitfalls.

The PrimeComposer Framework

The core innovation of PrimeComposer is treating composition as a subject-guided local editing task. Rather than rebuilding the image from scratch, the model focuses on the foreground area where the object will reside while preserving the background. This is achieved through several key technical components:

Correlation Diffuser (CD) and Attention Steering

The Correlation Diffuser acts as a secondary "steering" sampler. At each diffusion step, it takes a rough composite of the object and background to calculate how they should interact. It extracts "prior weights" from its self-attention layers—essentially a map of how the object's features relate to the scene.

These weights are then infused into the main generator's U-Net. Crucially, the researchers found that infusing appearance details only in the decoder part of the U-Net prevents "subject overfitting." This allows the encoder to first process the global style of the background, ensuring the object adopts the correct texture (e.g., becoming "painterly" in an oil painting) while maintaining its structural identity.

Region-constrained Cross-Attention (RCA)

To prevent "attribute leakage"—where a text prompt describing the object (e.g., "a yellow lemon") might inadvertently turn the entire background yellow—RCA uses a spatial mask. This ensures that text tokens describing the subject only influence the specific pixels where that subject is located.

Background Preserving Combining

To ensure the surrounding scene remains 100% unchanged, the newly edited foreground is merged with a precisely noised version of the original background at every diffusion step. This eliminates the "background drift" common in other generative methods.

Experimental Results and Performance

The researchers evaluated PrimeComposer using a cross-domain composition benchmark containing 332 samples across four distinct domains: Photorealism, Pencil Sketching, Oil Painting, and Cartoon Animation.

Key Findings:

  • Unprecedented Speed: PrimeComposer is the fastest training-free method to date. In photorealistic domains, it achieves an average inference time of 14.32 seconds, nearly twice as fast as TF-ICON's 30.55 seconds.
  • Superior Quality: In user studies, PrimeComposer consistently outscored baselines like Paint by Example and SDEdit across all artistic categories.
  • Semantic Alignment: Quantitative metrics, including CLIP (for text-image alignment) and LPIPS (for visual similarity to the reference object), showed significant improvements, confirming that the model better preserves the subject's identity while maintaining style consistency.

Limitations and Future Directions

While PrimeComposer represents a significant leap forward, the authors note a few remaining hurdles. The model currently struggles with viewpoint control; for example, it cannot easily rotate a front-facing reference object to fit a side-profile background. Additionally, the framework is currently optimized for single-object composition rather than complex scenes with multiple interacting subjects. Future work will focus on these structural challenges and further optimizing the pipeline for real-time interactive applications.

Summary updated

BibTeX
@inproceedings{wang2024primecomposer,
  author = {Yibin Wang and Weizhong Zhang and Jianwei Zheng and Cheng Jin},
  title = {{PrimeComposer: Faster Progressively Combined Diffusion for Image Composition with Attention Steering}},
  booktitle = {ACM Multimedia},
  year = {2024},
  doi = {10.1145/3664647.3680848},
}
Figure