Introduction
Diffusion-based image inpainting and outpainting have revolutionized digital image editing, allowing users to seamlessly fill holes or extend canvases. However, a persistent challenge remains: maintaining the integrity of the original "unmasked" pixels while ensuring the newly generated content blends perfectly. Standard diffusion models often regenerate the entire image, leading to subtle distortions in critical details like faces or text. To preserve original pixels, practitioners often "paste" them back over the generated output. This practice, while preserving detail, frequently introduces visible "seams," color mismatches, and structural discontinuities at the boundaries—a phenomenon often referred to as "ghost frames."
Addressing the Root Causes of Discontinuity
The authors identify two primary technical hurdles that lead to these boundary artifacts:
1. The VAE Bottleneck
Standard Variational Autoencoders (VAEs) are typically trained on complete images. When used in inpainting, they struggle to reconstruct latents that are partially masked or blended from different sources. This leads to noticeable color shifts when the decoded result is merged with the original image. To solve this, the researchers fine-tuned the VAE specifically for inpainting tasks. By modifying the reconstruction objective, they ensure that the transition between masked and generated latents remains color-continuous after decoding.
2. Training-Inference Mismatch
During inference, the "pasting" of original pixels happens at every denoising step. However, standard training paradigms do not account for this operation. This mismatch causes structural breaks where lines or textures fail to align at the edge.
The proposed solution is a Two-Step Training Paradigm:
- Step 1: The model performs a standard denoising step to predict the clean image ($z_0$).
- Step 2: The model simulates the actual inference process by blending its own prediction with the ground-truth original latent, adding noise back, and then re-predicting the noise. This "look-ahead" mechanism forces the U-Net to learn how to bridge the gap between its generated content and the fixed boundaries of the original image.
Experimental Setup and Results
The model was trained on a high-quality subset of the Laion-Aesthetic dataset (aesthetic score $\ge$ 6.0). Evaluation was conducted using BrushBench, with modified "convex hull" masks to test the model's ability to generate content based on context rather than mask shape.
Quantitative Performance
The proposed method significantly outperforms state-of-the-art (SOTA) models like PowerPaint and BrushNet across several metrics:
- Color Distance (CD): Achieved a score of 8.538, far lower than BrushNet (21.036) and PowerPaint (12.754), confirming much smoother color transitions.
- Image Quality: Recorded the best FID (15.434) and Aesthetic Score (5.991) among competitors.
Qualitative Comparison
Visual analysis reveals that the proposed method effectively eliminates the "rectangular frames" common in outpainting tasks. In human preference studies, the method was preferred 46% of the time for inpainting and 82% of the time for outpainting.
Conclusion and Future Directions
By addressing both the VAE's reconstruction limitations and the training-inference mismatch, this method achieves a new level of visual coherence in image editing. While currently based on Stable Diffusion 1.5, the principles of refined VAE training and simulated blending offer a promising path for larger architectures like SDXL. Future work will likely focus on reducing the computational overhead of the two-step training process and improving prompt adherence in complex, crowded scenes.
Summary updated