MaGIC: Multi-modality Guided Image Completion

Hao Wang, Yongsheng Yu, Tiejian Luo, Heng Fan, Libo Zhang

TL;DR

MaGIC is a novel framework that enables image completion (both inpainting and outpainting) guided by an arbitrary combination of modalities—such as text, sketches, depth maps, and poses—simultaneously. By utilizing a training-free "Consistent Modality Blending" (CMB) algorithm, it avoids the need for expensive joint re-training whenever a new guidance type is introduced.

MaGIC capabilities including large-scale outpainting and multi-modal inpainting

The Challenge of Image Completion

Traditional image completion methods often struggle when faced with large missing regions because they lack sufficient reference information to "hallucinate" a plausible result. To fix this, researchers have turned to auxiliary guidance, like using a sketch or a text prompt to tell the model what should be generated in the gap.

However, most existing tools are "single-modality" experts; they might handle a sketch or a text prompt, but combining them is difficult. The standard approach to combining multiple guidances is to jointly re-train a massive model on all combinations of inputs. This is computationally expensive and highly inflexible—if you want to add a new modality (like thermal maps or segmentation), you have to start the training process all over again. MaGIC aims to make multi-modal guidance scalable, flexible, and "plug-and-play."

How MaGIC Works

The authors break the problem down into two distinct stages to achieve flexibility without sacrificing quality:

1. MCU-Net (Modality-specific Conditional U-Net)

Instead of training one giant model to handle everything, the researchers train small, lightweight encoding networks for each individual modality (e.g., one specifically for Canny edges, another for depth). These encoders inject signals into a frozen, pre-trained Stable Diffusion U-Net. This allows the model to learn how a single modality should influence the image completion process independently.

2. CMB (Consistent Modality Blending)

This is the core innovation of the paper. CMB is a training-free algorithm used during the inference (denoising) stage. Rather than simply adding the features from different MCU-Nets together—which often pushes the model "out of distribution" and creates visual artifacts—CMB uses gradient guidance.

During each denoising step, the algorithm calculates the Euclidean distance (loss) between the features of the original unguided U-Net and the features of the various guided MCU-Nets. It then performs a backpropagation step to update the latent code. This effectively "pulls" the generation toward the guidance of all modalities simultaneously, while keeping the features safely within the distribution of the original model.

Key Insights

  • The Failure of Feature Addition: A major insight in the paper is the demonstration that simply adding features from different encoders (Feature-Level Addition or FLA) is impractical. It shifts the feature distribution so drastically that the pre-trained denoiser no longer recognizes them, leading to degraded image quality.
  • Gradient Guidance as a Universal Glue: By treating the difference between guided and unguided features as an "energy loss," the authors found they could steer the diffusion process without ever needing to train the modalities together.
  • Modality Complementarity: Different modalities provide different "resolutions" of control. Sketches provide fine-grained structural detail, while segmentation maps provide coarse-grained semantic layout. Using them together results in much more plausible completions than using either alone.

Datasets and Performance

To train their individual MCU-Nets, the researchers utilized several standard datasets: COCO (for Canny edge and sketch guidance), COCO-Stuff (for semantic segmentation), a 650k subset of LAION-AESTHETICS (for depth and pose guidance), and Places2 (for evaluating diverse, real-world scenes).

MaGIC demonstrates significant improvements over state-of-the-art methods like LAMA, MAT, and adapted versions of ControlNet:

  • Quantitative Gains: On the COCO dataset, MaGIC achieved a 21% gain in FID (measuring image quality and diversity) and a 61% gain in PickScore (measuring alignment with human preference) compared to its own single-modality baseline.
  • Qualitative Success: The model excels at complex tasks like "outpainting" (extending an image's borders) and "local editing" (changing a specific object based on a user's scribble and a text prompt). It maintains high spatial consistency, such as correctly aligning a generated mountain range with an existing horizon.

Limitations and Future Work

While powerful, MaGIC has a few limitations. First, backbone dependency: the quality of high-frequency details is still largely tied to the underlying Stable Diffusion backbone. If the backbone struggles to render a specific texture, MaGIC cannot easily fix it. Second, inference speed: because CMB requires backpropagation steps during the denoising process, inference time increases as more modalities are added, making it less efficient than a single-step, jointly-trained model.

Future directions include moving to more powerful, newer diffusion backbones to further improve realism, and optimizing the CMB algorithm to reduce computational overhead during inference.

Summary updated

BibTeX
@inproceedings{wang2024magic,
  author = {Hao Wang and Yongsheng Yu and Tiejian Luo and Heng Fan and Libo Zhang},
  title = {{MaGIC: Multi-modality Guided Image Completion}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=o7x0XVlCpX},
}
Figure