Mask-ControlNet: Higher-Quality Image Generation with an Additional Mask Prompt

Zhiqi Huang, Hui Xiong, Haoyu Wang, Longguang Wang, Zhiheng Li

Introduction

Current text-to-image (T2I) diffusion models, such as Stable Diffusion, have demonstrated remarkable capabilities in generating diverse imagery from textual descriptions. However, achieving fine-grained control over specific objects remains a significant challenge. When users attempt to transplant a specific object from a reference image into a new context, they often encounter issues such as structural distortion, background leakage, and lighting inconsistencies.

To address these limitations, we present Mask-ControlNet, a framework that introduces an additional "mask prompt" to the diffusion pipeline. By leveraging the Segment Anything Model (SAM) to isolate foreground objects, Mask-ControlNet effectively decouples an object's identity from its original environment, allowing for high-fidelity generation in diverse new settings.

The Challenge of Fine-Grained Control

Existing methods for personalized or controlled image generation often struggle with three primary issues:

  1. Object Distortion: Unique textures, logos, or specific geometric features of a reference object are frequently lost or altered during the diffusion process.
  2. Background Overfitting: Models often fail to distinguish the object from its surroundings, inadvertently carrying over elements of the original background into the new scene.
  3. Foreground-Background Inharmony: Even when the object is preserved, it may appear "pasted" onto the new background, lacking the necessary shadows, reflections, and environmental lighting to appear realistic.

These failures stem from the model's inability to explicitly separate the "identity" of the target object from its original "context."

Methodology

Mask-ControlNet introduces a dedicated image branch to the standard diffusion architecture, centered around the concept of a mask prompt.

The Mask Prompt and Decoupling

The process begins by using SAM to automatically generate a precise mask for the object of interest in a reference image. This mask is used to create a "segmented object image," where the object is isolated against a neutral background. By concatenating this segmented image with the original reference, the model receives explicit spatial and semantic information about what should be preserved.

Architecture and Integration

The concatenated input is processed through an adapter layer and a VAE encoder before being fed into a ControlNet structure. This ControlNet acts as a trainable copy of the diffusion model's encoding layers, guiding the frozen, pre-trained Stable Diffusion model. To maintain semantic consistency, the framework utilizes BLIP to generate textual descriptions of the reference image, which are then encoded via CLIP to provide global context.

Training Strategy

The model is trained using a self-supervised reconstruction task. It learns to reconstruct an original image using its segmented parts and textual hints. Crucially, the base diffusion model remains frozen throughout this process, with only the adapter and ControlNet layers undergoing updates. This preserves the generative power of the base model while adding the necessary control mechanisms.

Experimental Evaluation

The researchers trained Mask-ControlNet on a dataset of approximately 130,000 images and 300,000 masks, curated from web sources as well as the SA1B and COCO datasets.

Quantitative Results

Performance was benchmarked against state-of-the-art methods, including DreamBooth and ControlNet+LoRA, using the DreamBooth dataset. Mask-ControlNet demonstrated superior performance across several metrics:

  • FID (Fréchet Inception Distance): Achieved a score of 5.172, outperforming ControlNet+LoRA (6.161).
  • Fidelity: Higher PSNR and SSIM scores indicated better pixel-level adherence to reference objects.
  • Semantic Alignment: Improved CLIP-I and DINO scores confirmed that the generated objects maintained both semantic meaning and visual identity.

Qualitative Insights

Qualitative analysis revealed that Mask-ControlNet excels at rendering sharp textures (such as legible text on packaging) and realistic environmental interactions. Notably, the model demonstrates an emergent ability to handle refractions and reflections, correctly simulating how a glass object might interact with a new surface. Furthermore, the mask prompt allows for multi-object control, enabling users to select specific combinations of objects from a reference scene to port into a new generation.

User Study

A user study involving 207 participants further validated these results. When asked to identify real vs. generated images, 61.04% of participants could not distinguish Mask-ControlNet's outputs from reality. This significantly outperformed DreamBooth (15.59%) and Outpainting (18.19%).

Conclusion and Future Work

Mask-ControlNet represents a significant advancement in controlled image synthesis by explicitly decoupling object identity from context via mask prompts. While the framework shows high efficacy, it remains dependent on the quality of the initial SAM segmentation. Future research may focus on reducing the computational overhead of the additional ControlNet branch and exploring more complex object-environment interactions, such as physical deformation or partial submersion.

Summary updated

BibTeX
@inproceedings{huang2024mask,
  author = {Zhiqi Huang and Hui Xiong and Haoyu Wang and Longguang Wang and Zhiheng Li},
  title = {{Mask-ControlNet: Higher-Quality Image Generation with an Additional Mask Prompt}},
  booktitle = {ICPR},
  year = {2024},
  url = {https://openreview.net/forum?id=UVS7fMzitv},
}
Figure