CM-GAN: Image Inpainting with Cascaded Modulation GAN and Object-Aware Training

Haitian Zheng, Zhe Lin, Jingwan Lu, Scott Cohen, Eli Shechtman, Connelly Barnes, Jianming Zhang, Ning Xu, Sohrab Amirghodsi, Jiebo Luo

TL;DR

CM-GAN (Cascaded Modulation GAN) is a novel image inpainting framework that excels at filling large holes in complex scenes by combining global semantic guidance with spatially adaptive refinement. By introducing a dual-stream decoder and an object-aware training scheme, the authors achieve a new state-of-the-art in generating realistic, coherent structures for real-world object removal tasks.

What Problem Does This Paper Address?

Image inpainting—the art of filling in missing parts of an image—has seen massive leaps thanks to Generative Adversarial Networks (GANs). However, two major hurdles remain:

  1. Structural Coherence in Large Holes: When a large portion of an image is missing, models often struggle to maintain global consistency. They might generate realistic textures locally but fail to reconstruct the overall "logic" of the scene, resulting in distorted structures or strange "color blobs."
  2. Training-Testing Mismatch: Most models are trained using random geometric masks (like rectangles or scribbles). In the real world, users typically want to remove specific objects. Models trained on random shapes often fail to respect object boundaries, leading to "color bleeding" or the hallucination of nonsensical objects inside the hole.

Methods

The authors propose a multi-pronged approach to solve these issues through architectural innovation and a smarter training pipeline.

1. The CM-GAN Architecture

The network uses an encoder-decoder structure with several key modifications:

  • Fast Fourier Convolution (FFC) Encoder: Standard convolutions have a limited "view" (receptive field). By using FFCs, the encoder can capture long-range dependencies across the entire image right from the start, which is crucial for understanding the global context of a large hole.
  • Cascaded Modulation Decoder: This is the core innovation. The decoder features two parallel branches: a Global Modulation Block (GB) and a Spatial Modulation Block (SB).
  • The GB uses a global style code to establish a coarse, semantically consistent structure.
  • The SB then takes the output of the GB to perform spatially adaptive refinement, injecting fine-grained details while ensuring they align with the global plan.
The CM-GAN architecture featuring the dual-stream decoder and cascaded modulation blocks.

2. Object-Aware Training (OT)

Instead of just using random masks, the authors leverage panoptic segmentation to create masks that mimic real-world object removal. They specifically filter these masks to ensure the model doesn't try to "complete" an object that is mostly gone, which discourages the network from hallucinating new, distorted objects where they don't belong.

3. Masked $R_1$ Regularization

Standard GAN regularization penalizes the discriminator's gradients across the whole image. The authors found that for inpainting, it's better to only penalize gradients inside the masked region. This prevents the "real" parts of the image from interfering with the training of the generated content, leading to more stable convergence.

Datasets

The model was primarily trained and evaluated on the Places2 dataset, a standard benchmark containing over 10 million images of various scenes. To test generalization, they used:

  • Object-aware masks (generated via PanopticFCN).
  • Wide masks and CoModGAN masks from previous literature to ensure a fair comparison across different hole types.

Key Insights and Ideas

  • Global-to-Local Refinement: The "aha moment" here is that global modulation alone is too blunt, and spatial modulation alone is too local. By cascading them—using the global branch to inform the spatial branch—the model achieves a "best of both worlds" result.
  • Decoder-Sourced Spatial Codes: Unlike previous methods that used "corrupted" encoder features (which contain the hole) for spatial modulation, CM-GAN uses features generated within the decoder itself. This ensures the modulation signal is clean and focused on synthesis.
  • Visualizing the Process: The authors provide a fascinating look at how features evolve. As seen in Figure 3, the global feature sets the stage with coarse shapes, while the spatial feature sharpens the boundaries and textures.
Fig. 3: Visualization of the intermediate features for inpainting. From left to right are the incomplete image, encoded feature, our globally modulated feature and spatially modulated features at the 256 × 256 layer and the output image.

Key Results

CM-GAN significantly outperformed existing state-of-the-art methods like LaMa and CoModGAN across all metrics:

  • Quantitative: On the Places2 dataset, CM-GAN reduced the Fréchet Inception Distance (FID)—a measure of image realism—by over 50% compared to LaMa (dropping from 3.864 to 1.628).
  • Qualitative: Visual comparisons show that CM-GAN produces much sharper edges and more plausible structures in complex scenarios, such as reconstructing a baseball field or a forest path, where competitors often produce blurry or distorted artifacts.
Fig. 1: Results of CM-GAN in comparison to state of the art methods: ProFill [57], LaMa [44] and CoModGAN [59]. CM-GAN generates more plausible and realistic re- sults for the distractor removal scenario (1st row) and large holes (2nd row).
  • User Preference: In a user study, CM-GAN was preferred by participants in 58% of cases for object-aware masks, compared to just 20% for the next best model.

Limitations and Future Work

Despite its success, the authors note that CM-GAN still struggles with synthesizing large, complex biological entities like humans or animals from scratch. Because these require very specific anatomical knowledge, a general-purpose scene inpainter can sometimes fail.

Future work may involve training specialized models for specific object categories or integrating depth information and semantic maps to provide even stronger structural priors for the synthesis process.

Summary updated

BibTeX
@misc{zheng2022cm,
  author = {Haitian Zheng and Zhe Lin and Jingwan Lu and Scott Cohen and Eli Shechtman and Connelly Barnes and Jianming Zhang and Ning Xu and Sohrab Amirghodsi and Jiebo Luo},
  title = {{CM-GAN: Image Inpainting with Cascaded Modulation GAN and Object-Aware Training}},
  year = {2022},
  eprint = {2203.11947},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2203.11947},
}
Figure