Abstract
Traditional image inpainting models often function as "black boxes," offering limited user control over the generated content. We propose a novel two-stage interactive framework that leverages an editable semantic mask and an External Spatial Attention (ESPA) mechanism. This system allows users to specify the "what" and "where" of reconstructed regions, producing high-quality, contextually coherent results that maintain the original image's stylistic consistency.
Introduction
Image inpainting has evolved from simple texture synthesis to complex deep learning-based object imagination. Despite these advancements, a significant gap remains in controllability. Most existing models provide either a single deterministic output or random variations, leaving users unable to specify particular objects or features in missing regions. Furthermore, previous attempts at controllable inpainting often sacrificed original color and texture information by relying solely on edges or semantic maps in the final generation stage.
Methodology
The proposed framework addresses these challenges through a two-stage pipeline that balances automated priors with explicit user guidance.
Stage 1: ESPA Autoencoder and Coarse Reconstruction
The first stage generates a coarse inpainting result using an autoencoder enhanced by the External Spatial Attention (ESPA) module. Unlike standard self-attention mechanisms with $O(N^2)$ complexity, ESPA utilizes two external, learnable parameter matrices to model long-range dependencies with linear complexity. This allows the model to capture global context more efficiently, leading to a more accurate initial reconstruction.
The Interactive Semantic Medium
The coarse output from Stage 1 is processed by a pre-trained segmentation network to produce a semantic mask. This mask serves as the primary interface for user interaction. By editing labels within this mask (e.g., modifying facial features or landscape elements), users can directly influence the content of the final output.
Stage 2: Semantic Decoder and Final Generation
In the second stage, the encoded features from Stage 1—which preserve the original image's color and texture—are combined with the edited semantic mask. Spatially Adaptive Normalization (SPADE) layers are employed to inject this semantic guidance into the generation process. This decoupling of content (defined by the mask) and style (preserved from the original features) ensures high-fidelity results without the "washed out" appearance common in other multi-stage methods.
Experimental Results
The model was evaluated on high-resolution benchmarks including FFHQ, CelebA-HQ, and Outdoorscenes, using both regular and irregular masks.
Quantitative Performance
On the Outdoorscenes dataset, the proposed method achieved a PSNR of 22.20 and an SSIM of 0.81. Notably, it reached a Fréchet Inception Distance (FID) of 3.86 on CelebA-HQ, outperforming state-of-the-art baselines and indicating superior perceptual quality.
Qualitative Comparison
Qualitative assessments demonstrate the model's ability to maintain stability and realism while allowing for precise content manipulation. As shown in Figure 2, our method produces more coherent facial features and textures compared to EdgeConnect (EC) and SPG-Net, especially when responding to specific semantic edits.
Conclusion
This research introduces a controllable approach to image inpainting by integrating semantic masks and efficient spatial attention. By separating content guidance from stylistic features, the framework provides users with an intuitive yet powerful tool for image restoration. Future work will explore the integration of reference images to provide additional control over the style and texture of the inpainted regions.
Summary updated