TF-ICON: Diffusion-Based Training-Free Cross-Domain Image Composition

Shilin Lu, Yanzhu Liu, Adams Wai-Kin Kong

Abstract

Image composition—the integration of a foreground object into a background image—is a fundamental task in visual editing. While photorealistic composition has seen significant progress, "cross-domain" composition (e.g., placing a real-world object into an artistic painting) remains a challenge due to the difficulty of maintaining object identity while adapting to the target domain's style. We present TF-ICON (Training-Free Image COmpositioN), a framework that leverages pre-trained diffusion models to achieve seamless cross-domain blending without additional training or fine-tuning. By introducing an "exceptional prompt" for accurate image inversion and a composite self-attention injection mechanism, TF-ICON preserves the structural integrity of foreground objects while harmonizing them with diverse artistic contexts.

1. Introduction

Traditional image composition methods often struggle with domain gaps, such as inserting a photorealistic animal into a sketch or an oil painting. Existing diffusion-based approaches typically rely on costly optimization (e.g., DreamBooth) or fine-tuning, which can damage the model's generative priors and lead to stylistic artifacts. TF-ICON addresses these limitations by providing a training-free pipeline that operates directly on the latent space of off-the-shelf diffusion models, achieving high-quality results in approximately 20 sampling steps.

2. Methodology

TF-ICON utilizes a two-stage process: precise inversion of source images into the latent space followed by a controlled denoising process for composition.

2.1 Inversion with the "Exceptional Prompt"

To edit real-world images, they must first be mapped back to the model's latent noise space (inversion). Standard DDIM inversion often suffers from reconstruction errors when using Classifier-Free Guidance (CFG). TF-ICON introduces the Exceptional Prompt ($P_{exceptional}$) to solve this. Unlike standard "null" prompts, which still contain positional embeddings and special tokens that introduce bias, the exceptional prompt sets all tokens to a uniform value and removes positional embeddings entirely. Combined with high-order ODE solvers (DPM-Solver++), this approach achieves near-perfect reconstruction of the original images.

2.2 Composite Self-Attention Injection

The composition stage occurs during the denoising process. To ensure the foreground object retains its identity while adopting the background's style, TF-ICON employs Composite Self-Attention Injection.

During denoising, the framework injects a composite self-attention map derived from three sources: the background's original self-attention, the foreground's self-attention, and a cross-attention map calculated between the two. This mechanism "locks" the geometric structure and identity of the object while allowing the background's stylistic features—such as brushstrokes, lighting, and texture—to permeate the object's appearance.

3. Evaluation and Results

3.1 Benchmarking

As no standard cross-domain composition benchmark existed, the authors curated a new dataset of 332 samples, spanning photorealism, oil paintings, pencil sketches, and cartoon animations. Performance was also evaluated on standard datasets like CelebA-HQ, COCO, and ImageNet for inversion accuracy.

3.2 Performance Metrics

  • Reconstruction Accuracy: On CelebA-HQ, TF-ICON achieved a Mean Absolute Error (MAE) of 0.019 and a Structural Similarity Index (SSIM) of 0.918, significantly outperforming DiffusionCLIP and various GAN-based encoders.
  • User Preference: In a study involving 50 participants, TF-ICON was preferred over baselines like Blended Diffusion and Paint-by-Example, receiving an average score of 4.175/5.
  • Efficiency: The training-free nature of the framework allows for rapid execution, taking roughly 8 seconds on a single NVIDIA A100 GPU.

4. Discussion and Limitations

TF-ICON demonstrates that the semantic layout of an image is largely governed by self-attention layers. By manipulating these layers, it is possible to achieve complex edits without altering model weights. However, the method has limitations:

  • Viewpoint Rigidity: The framework relies on the spatial layout of the reference image. It cannot currently perform 3D rotations or significant perspective shifts to align a foreground object with a background's viewpoint.
  • Model Bias: Since the method is training-free, it is subject to the inherent biases and limitations of the underlying Stable Diffusion model.

5. Conclusion

TF-ICON provides a robust, efficient, and training-free solution for cross-domain image composition. By leveraging the "Exceptional Prompt" and attention injection, it maintains a delicate balance between identity preservation and stylistic harmony, making it a versatile tool for interactive visual editing and creative workflows.

Summary updated

BibTeX
@inproceedings{lu2023tf,
  author = {Shilin Lu and Yanzhu Liu and Adams Wai-Kin Kong},
  title = {{TF-ICON: Diffusion-Based Training-Free Cross-Domain Image Composition}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2023},
}
Figure