Labels4Free: Unsupervised Segmentation using StyleGAN

Rameen Abdal, Peihao Zhu, Niloy J. Mitra, Peter Wonka · DOI

TL;DR

This paper introduces "Labels4Free," a novel unsupervised framework that leverages the internal representations of StyleGAN to generate segmentation masks for foreground objects. By cleverly augmenting the StyleGAN architecture and training a "weak" discriminator, they achieve state-of-the-art unsupervised segmentation and even produce comparable results to supervised methods, opening doors for generating large, labeled synthetic datasets.

What Problem Does This Paper Address?

Generating high-quality segmentation masks for images typically requires large datasets with meticulously annotated ground truth masks. This manual annotation process is time-consuming and expensive, limiting the scalability of segmentation models. While Generative Adversarial Networks (GANs) like StyleGAN can produce incredibly realistic images, it's not immediately obvious how to extract semantic information like object boundaries from their internal workings without explicit supervision. This paper tackles the challenge of obtaining accurate object segmentation masks without relying on any human-labeled data, specifically by exploiting the rich semantic information already learned by StyleGAN.

Methods

The core of Labels4Free lies in modifying the StyleGAN2 architecture. They introduce an "Alpha Network" (A) that acts as a segmentation branch, taking features from the StyleGAN generator (G) to predict a soft segmentation mask (M). This Alpha Network is trained alongside a "weak" discriminator (D) that is trained from scratch. The key idea is to treat foreground and background as potentially independent components that can be swapped and recomposited.

Here's a breakdown of their approach:

  • Augmented StyleGAN Generator: The original StyleGAN generator is augmented with a segmentation branch (Alpha Network). This network learns to output an alpha mask, effectively separating foreground from background.
  • Foreground/Background Split: The framework implicitly splits the generation process. The original StyleGAN generator (G) is used for foreground generation, while a modified, "trimmed" StyleGAN generator (Gbg) is used for background generation. This trimming involves identifying and zeroing out channels in a specific layer that are most responsible for generating background elements, effectively isolating background generation.
  • Weak Discriminator: A crucial aspect is training a discriminator from scratch. This "weak" discriminator is hypothesized to be less biased by pre-existing correlations between foreground and background (like shadows or lighting) that a pre-trained discriminator might have learned, allowing the Alpha Network to learn segmentation more effectively.
  • Unsupervised Training: The Alpha Network and the weak discriminator are trained adversarially. The loss function encourages the Alpha Network to produce masks that, when used to composite foreground from G and background from Gbg, fool the discriminator into thinking the result is a real image.
  • Synthetic Dataset Generation: A significant byproduct is the ability to generate large, high-quality, labeled synthetic datasets for various object classes. These datasets can then be used to train other supervised segmentation networks.

Datasets

The authors leverage pre-trained StyleGAN2 models on several datasets:

  • FFHQ: A high-quality dataset of human faces (1024x1024 resolution).
  • LSUN-Object: This includes subcategories for:
  • LSUN-Cars
    • LSUN-Cats
    • LSUN-Horse

They also created a custom evaluation dataset consisting of 10 images per class, which was used for direct comparison with supervised methods.

Key Insights and Ideas

  • GANs Encode Segmentation Information: The most significant insight is that the internal feature representations of StyleGAN, even without explicit segmentation supervision, contain rich semantic information that can be leveraged to infer object boundaries.
  • Foreground and Background Independence: The assumption that foreground and background can be treated as largely independent and composited in various ways is key to the framework's success. This allows for disentangling these components.
  • "Weak" Discriminator for Unsupervised Learning: Training a discriminator from scratch, rather than using a pre-trained one, is critical for enabling the unsupervised learning of segmentation. This prevents the discriminator from being overly biased by learned correlations.
  • Synthetic Data as a Powerful Tool: The ability to generate large, labeled synthetic datasets is a major contribution. This can democratize segmentation research by providing readily available training data for various object classes.
  • Layer-Specific Feature Importance: The paper highlights that specific layers within StyleGAN (e.g., the 4th layer for faces) are particularly important for capturing structural information relevant to segmentation.

Key Results

  • Quantitative Performance: Labels4Free achieves comparable results to state-of-the-art supervised segmentation networks on multiple object classes. Against the best existing unsupervised segmentation approach (PSeg), it demonstrates a clear improvement in both qualitative and quantitative metrics. For instance, on FFHQ, their method achieves an IOU of 0.87/0.94 (foreground/background) compared to PSeg's 0.52/0.82.
  • Qualitative Performance: The generated segmentation masks are visually impressive, accurately capturing object boundaries even in complex scenes. The method also shows good performance on real images projected into the StyleGAN2 latent space.
  • Background Preservation: The framework enables background-preserving edits in image manipulation tasks, addressing a limitation of existing editing methods.
  • Efficiency: The training process is relatively fast, with models converging in under 30 minutes on multiple RTX 2080 GPUs.

Limitations and Future Work

  • Dependence on StyleGAN Quality: The performance of Labels4Free is inherently tied to the quality and domain of the pre-trained StyleGAN model. If the StyleGAN generates low-quality or out-of-distribution samples, segmentation accuracy may suffer.
  • Multiple Instances: While the paper shows some capability in handling multiple objects, it's noted that StyleGAN itself can struggle with multiple instances in a scene, which can affect segmentation performance.
  • Future Work: The authors suggest exploring unsupervised extraction of other information, such as illumination, and extending the framework to segment into additional classes beyond foreground/background. They also mention the potential for further improvements by using features from multiple layers in the generator for higher fidelity.

Summary updated

BibTeX
@inproceedings{abdal2021labels,
  author = {Rameen Abdal and Peihao Zhu and Niloy J. Mitra and Peter Wonka},
  title = {{Labels4Free: Unsupervised Segmentation using StyleGAN}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2021},
  doi = {10.1109/iccv48922.2021.01371},
}
Figure