TL;DR
SourceSwap is a novel zero-shot object swapping framework that achieves exceptional object fidelity and natural scene harmony without requiring slow test-time finetuning or expensive video/multi-view training data. By generating high-quality pseudo-image pairs via frequency-separated initial noise perturbation, it explicitly teaches diffusion models how to align distinct objects within a shared background context.
What Problem Does This Paper Address?
Object swapping is a deceptively challenging task in controllable image generation. Given a source image, the goal is to replace a specific object with a reference object from another image. A successful swap must satisfy three strict criteria:
- Object Fidelity: The swapped object must preserve the fine details and identity of the reference.
- Scene Fidelity: The background and surrounding context must remain completely unchanged.
- Object-Scene Harmony: The new object must naturally adapt to the original scene's lighting, viewpoint, and physical interactions.
Existing solutions typically fall into two flawed categories. Test-time personalization methods (like DreamBooth variants) require slow, hyperparameter-sensitive finetuning for every single object. On the other hand, learning-based inpainting methods bypass test-time tuning but rely on training data derived from videos or multi-view captures. These datasets are expensive to curate, often blurry, and usually depict the same object across different contexts. Consequently, models learn to rely on background cues rather than learning true cross-object alignment, leading to unnatural boundaries and poor structural harmony.
Methods
SourceSwap introduces a two-phase framework that eliminates the need for external paired data or test-time tuning:
1. Initial Noise Perturbation (Data Construction)
To teach the model how different objects behave in the same scene, the authors design a clever self-supervised pairing mechanism from single images. They perform DDIM inversion on a source image to obtain its initial noise latent ($z_T$). Using a Fast Fourier Transform (FFT), they split this noise into low- and high-frequency components. By applying a local random permutation only to the high-frequency components within the object's mask, they alter the object's texture, color, and material while perfectly preserving its coarse shape, pose, and background layout.
2. Source-Aware Training
Instead of masking out the source object during training (which forces the network to blindly guess what fills the hole), SourceSwap employs a Source-Aware Dual U-Net architecture.
- Reference U-Net: Extracts clean, noise-free features from the target reference object.
- Denoising U-Net: Observes the entire unmasked source image as a condition, alongside a loose bounding-box mask ($M_{bbox}$) rather than a tight, restrictive mask.
This full-source conditioning allows the denoiser to directly map inter-object correspondences and maintain natural object-background boundaries.
3. Iterative Refinement
Because the model takes the full image as an input condition, it naturally supports zero-shot iterative refinement at test time. The output of one inference round can be fed directly back as the input for the next, progressively sharpening textures and color gradients without any extra training.
Datasets
- Training Data: 43k single-image pseudo pairs synthesized automatically from a subset of the LAION-Aesthetic dataset (BrushData).
- Evaluation Benchmarks:
- DreamEditBench: A standard personalization benchmark.
- SourceBench (New): Introduced by the authors to address the limited category diversity of older benchmarks. SourceBench contains 54 categories, 577 distinct object instances, and 1,554 source-reference pairs featuring high-resolution real-world photos with complex object-scene interactions (e.g., hands holding objects, occlusions).
Key Insights and Ideas
- High Frequencies Control Identity, Low Frequencies Control Layout: The authors discovered a sweet spot in the diffusion model's initial noise space. Permuting all noise components causes severe structural distortion, while permuting only low frequencies yields negligible changes. Permuting exclusively the high-frequency components successfully alters appearance while locking the object's geometry and pose in place.
- Don't Hide the Source Object: Traditional inpainting paradigms treat the source object as a black hole to be filled. By keeping the source object visible to the denoiser during training, the network learns a direct translation function from "Source Object Pose/Shape" to "Reference Object Appearance," drastically reducing boundary artifacts.
- The Feedback Loop Advantage: Operating on unmasked full scenes allows the model to act as its own refiner. Iterative inference acts like a multi-pass painter, correcting color mismatches and adding fine-grained textures in later passes.
Key Results
- State-of-the-Art Fidelity: SourceSwap consistently outperforms competitive baselines (including AnyDoor, MimicBrush, and Paint-by-Example) on the Pareto frontier of reference object fidelity (measured via DreamSim) and scene preservation (measured via local LPIPS).
- Human and MLLM Preference: In a Two-Alternative Forced Choice evaluation using ChatGPT-5 to judge object-scene harmony, SourceSwap was heavily preferred over baselines (e.g., preferred over AnyDoor 83.33% of the time on DreamEditBench).
- Drastic Speedup: Because it requires no test-time optimization, SourceSwap takes only 4.41 seconds per sample (using 2 rounds of iterative refinement) on a single NVIDIA A100 GPU. This is significantly faster than other learning-based methods like AnyDoor (11.01s) and orders of magnitude faster than test-time tuning methods like PhotoSwap (~880s).
- Data Efficiency: SourceSwap achieves these results using only 40k single-image training samples, compared to competitors that require millions of multi-view images or video frames.
Limitations and Future Work
The primary limitation of SourceSwap is its reliance on the localization quality of off-the-shelf segmentation tools (like Grounded SAM). If a mask is ambiguous—for instance, selecting an entire cluster of lemons instead of a single target lemon—the model receives conflicting control signals and may inadvertently swap every instance in that region.
The authors note that a promising future direction is developing mask-free architectures or integrating lightweight, point-based user interactions (such as a single click) to resolve multi-instance ambiguities.
Summary updated