Abstract
We offer a novel approach to image composition, which integrates multiple input images into a single, coherent image. Rather than concentrating on specific use cases such as appearance editing (image harmonization) or semantic editing (semantic image composition), we showcase the potential of utilizing the powerful generative prior inherent in large-scale pre-trained diffusion models to accomplish generic image composition applicable to both scenarios. We observe that the pre-trained diffusion models automatically identify simple copy-paste boundary areas as low-density regions during denoising. Building on this insight, we propose to optimize the composed image towards high-density regions guided by the diffusion prior. In addition, we introduce a novel mask-guided loss to further enable flexible semantic image composition. Extensive experiments validate the superiority of our approach in achieving generic zero-shot image composition. Additionally, our approach shows promising potential in various tasks, such as object removal and multi-concept customization.
Introduction
Image composition—the process of fusing a foreground object from one source into a new background—remains a significant challenge in computer vision. The difficulty lies in achieving two distinct goals: Image Harmonization, which involves adjusting low-level features like lighting and color to ensure the object fits the scene, and Semantic Composition, which requires high-level structural adjustments to make the object's pose or interaction with the environment appear natural.
Traditional learning-based methods rely on massive datasets of image triplets (foreground, background, and ground-truth composite), which are difficult to curate for "in-the-wild" scenarios. Furthermore, these models are often specialized for only one type of composition. FreeCompose introduces a generic, zero-shot framework that leverages the internal generative priors of large-scale diffusion models to perform seamless composition without any task-specific training.
Methodology: Diffusion Prior as a Naturalness Detector
The core innovation of FreeCompose is the realization that a pre-trained diffusion model (such as Stable Diffusion) acts as a statistical "naturalness detector." When an object is naively copy-pasted into a background, the resulting image contains boundary artifacts and lighting inconsistencies that the diffusion model identifies as low-density regions during the denoising process.
The Delta Denoising Score (DDS) Loss
FreeCompose utilizes the Delta Denoising Score (DDS) loss to optimize the pixels of the composite image. Instead of generating an image from scratch, the framework uses the gradients produced by the diffusion model to "nudge" the unnatural copy-pasted state toward a high-probability, realistic state. This optimization process is guided by three distinct phases:
- Object Removal: Before inserting a new object, the model can clear a target area using a mask-guided loss. By manipulating the Key ($K$) and Value ($V$) embeddings in the UNet’s self-attention layers, the model is forced to reconstruct the masked region using context from the surrounding background.
- Image Harmonization: The model adjusts the foreground object to match the background's environmental conditions. To prevent the object from losing its original identity, the framework employs separate perceptual losses for the foreground and background.
- Semantic Image Composition: For more complex edits where an object's pose must change, FreeCompose uses text prompts or sketches as additional guidance. A $K, V$ replacement strategy in the self-attention layers ensures that while the structure shifts, the specific identity of the object is preserved.
Results and Evaluation
FreeCompose was evaluated using Stable Diffusion V2.1 and AnyLoRA for diverse artistic styles. In a user study involving over 20 volunteers, the framework consistently outperformed specialized baselines.
- Object Removal: FreeCompose achieved a quality score of 4.47/5.0, surpassing specialized models like Lama (4.14) by better handling secondary artifacts like shadows.
- Image Harmonization: The framework earned a top rating of 3.69/5.0 for harmony, compared to DucoNet’s 3.14. It proved particularly adept at generating realistic environmental effects, such as casting background shadows over newly inserted objects.
- Identity Preservation: While the model excels at realism, it faces a slight trade-off in identity preservation (4.11 vs. DucoNet's 4.16), as the strong diffusion prior occasionally over-corrects unique object features to satisfy the background's lighting constraints.
Conclusion
FreeCompose demonstrates that the generative priors of large-scale diffusion models are sufficient for high-quality, zero-shot image composition. By treating composition as an optimization problem toward high-density regions, the framework handles removal, harmonization, and semantic editing within a single pipeline. While the iterative optimization process is slower than feed-forward models, its versatility and performance in "open-world" scenarios mark a significant step forward for generic image editing.
Summary updated