Structure Matters: Tackling the Semantic Discrepancy in Diffusion Models for Image Inpainting

Haipeng Liu, Yang Wang, Biao Qian, Meng Wang, Yong Rui

Introduction

Image inpainting—the process of reconstructing missing or damaged regions of an image—has undergone a paradigm shift with the advent of Denoising Diffusion Probabilistic Models (DDPMs). While these models excel at generating high-fidelity textures, they often struggle with a phenomenon known as "semantic discrepancy." This occurs when the generated content fails to align logically or visually with the surrounding unmasked regions.

This paper introduces StrDiffusion, a novel framework designed to bridge this gap. By leveraging a progressively sparse auxiliary structure to guide the denoising process, StrDiffusion ensures that newly generated content is both semantically coherent and contextually consistent.

The Challenge: Semantic Discrepancy

In standard diffusion-based inpainting, the masked region is initialized as pure Gaussian noise, while the unmasked regions retain their original, dense textures. During the reverse diffusion process, the model attempts to reconcile these two vastly different information densities.

The "semantic discrepancy" arises because the transition from empty noise to complex texture is too abrupt. This often results in visual artifacts, such as "seams" at the mask boundaries, inconsistent color palettes, or structural illogicalities where the inpainted patch does not match the perspective or geometry of the original image.

Methodology: StrDiffusion

StrDiffusion reformulates the inpainting objective by introducing Structure Guidance as a mediator between noise and texture.

1. Progressive Sparsity

The core innovation of StrDiffusion is the use of an auxiliary "structure" scaffold, such as grayscale maps or edge maps. The researchers observed that while dense textures are difficult to align early in the denoising process, sparse structures provide a manageable "bridge." StrDiffusion employs a strategy where the model initially follows a sparse structural guide and gradually shifts toward generating dense, realistic textures as the denoising progresses.

2. Structure-Guided Neural Network

To integrate this guidance, the authors developed a network architecture utilizing a multi-scale spatially adaptive normalization strategy. This allows structural information to inform the generation process across multiple layers of the neural network, ensuring that the global geometry of the image is preserved while fine-grained details are filled in.

3. Adaptive Resampling Strategy

During inference, StrDiffusion employs an adaptive resampling loop. A discriminator evaluates the "semantic correlation" between the emerging texture and the underlying structure. If the consistency is insufficient, the model triggers a resampling step to refine the region, ensuring the final output is logically grounded in the surrounding context.

Experimental Evaluation

The model was evaluated on three high-complexity benchmarks: Paris StreetView (PSV), CelebA (facial attributes), and Places2 (diverse natural and urban scenes). Testing involved irregular masks to simulate real-world object removal and image damage.

Quantitative Performance

StrDiffusion demonstrated superior performance over existing state-of-the-art (SOTA) models like IR-SDE and RePaint. On the Places2 dataset with a 40-50% mask ratio, StrDiffusion achieved:

  • PSNR: 22.37 (compared to IR-SDE's 21.68)
  • FID: 36.93 (compared to IR-SDE's 39.77)

The lower FID (Fréchet Inception Distance) score is particularly significant, as it indicates that the images generated by StrDiffusion are more realistic and closer to the distribution of real-world images.

Qualitative Insights

Visually, StrDiffusion effectively eliminates common inpainting artifacts. In facial reconstruction (CelebA), the model maintains structural symmetry and skin tone consistency. In architectural scenes (PSV), it preserves straight lines and perspective more effectively than models that ignore the semantic discrepancy.

Discussion and Key Insights

The success of StrDiffusion highlights that sparsity acts as a bridge. By reducing the complexity of the guidance signal in the early stages of diffusion, the model can establish a global consistency that dense textures would otherwise obscure. The "Gray2Edge" strategy—moving from a grayscale representation to a sparse edge map—was found to be more effective than using a static structural guide, as it strengthens sparsity over time.

Limitations and Future Directions

Despite its performance, StrDiffusion has limitations. The adaptive resampling strategy increases computational overhead during inference, making it slower than some GAN-based alternatives. Additionally, the model's performance is inherently linked to the quality of the pre-trained structure denoising network.

Future research may explore alternative forms of guidance, such as semantic segmentation or depth maps, to further enhance the model's performance in extremely complex or high-resolution environments.

Summary updated

BibTeX
@inproceedings{liu2024structure,
  author = {Haipeng Liu and Yang Wang and Biao Qian and Meng Wang and Yong Rui},
  title = {{Structure Matters: Tackling the Semantic Discrepancy in Diffusion Models for Image Inpainting}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2024},
  url = {https://openreview.net/forum?id=XRkLBFHBDH},
}
Figure