HairMapper: Removing Hair from Portraits Using GANs

Xiaogang JinOpenReview 2022

Abstract

Removing hair from portrait images is challenging due to the complex occlusions between hair and face, as well as the lack of paired portrait data with/without hair. To this end, we present a dataset and a baseline method for removing hair from portrait images using generative adversarial networks (GANs). Our core idea is to train a fully connected network HairMapper to find the direction of hair removal in the latent space of StyleGAN for the training stage. We develop a new separation boundary and diffuse method to generate paired training data for males, and a novel “female-male-bald” pipeline for paired data of females. Experiments show that our method can naturally deal with portrait images with variations on gender, age, etc. We validate the superior performance of our method by comparing it to state-of-the-art methods through extensive experiments and user studies. We also demonstrate its applications in hair design and 3D face reconstruction.

Introduction

Removing hair from a portrait is a complex task that goes beyond simple digital erasure. Hair often occludes significant portions of the face, such as the forehead and temples. Removing it requires filling these "holes" with plausible skin textures, shadows, and anatomical structures that maintain the subject's original identity.

Existing generative models, particularly StyleGAN, struggle with this task for two primary reasons. First, there is a severe lack of paired datasets showing the same individual with and without hair. Second, StyleGAN’s latent space often lacks a robust representation for "bald women," making it difficult to find a simple hair-removal trajectory for female portraits without compromising facial identity.

The HairMapper Framework

To address these challenges, we propose HairMapper, a framework designed to find a non-linear "hair removal path" within the StyleGAN latent space ($W+$). Unlike standard linear editing methods, HairMapper uses a fully connected network to learn the intricate relationship between hair, skin, and identity.

HairMapper effectively removes hair while preserving facial identity.

The "Female-Male-Bald" Pipeline

Because StyleGAN does not naturally generate bald women, we utilize a "domain pivoting" strategy. To create training data for females, we first transform a female latent code into a male one while preserving identity and pose. We then apply a male hair-removal mapper and use a diffusion process to blend the baldness back into the original female identity. This allows us to "borrow" the robust baldness attributes from the male domain and apply them to female subjects.

Identity-Preserving Diffusion and Blending

To ensure the subject remains recognizable, we employ an optimization-based diffusion process that uses the original face as a prior to fill in the skin where hair used to be. For the final output, we use Poisson editing to blend the generated bald scalp with the original face. Crucially, we dilate and blur the hair mask to target and remove the subtle shadows hair casts on the forehead, leading to significantly more realistic results.

Datasets

Our research utilized several key resources:

  • CelebAHQ-mask: Used to train a hair classifier to score the "baldness" of generated images.
  • FFHQ: The primary source for high-quality portrait images.
  • Non-hair-FFHQ: We introduce a new benchmark dataset containing 6,000 high-quality portrait images with hair removed to facilitate future research in this field.

Results and Applications

In quantitative tests using ArcFace to measure identity preservation ($L_{id}$), HairMapper outperformed state-of-the-art methods like InterFaceGAN, StyleClip, and StyleFlow. In a user study, 48.37% of participants labeled HairMapper results as "untouched" real images, a significantly higher score than competing methods.

The pipeline enables high-quality 3D face reconstruction by providing clean facial textures.

Beyond simple image editing, HairMapper serves as a critical tool for downstream applications. In 3D face reconstruction, hair "baked" into facial textures often creates messy artifacts. By providing a "clean slate" texture, HairMapper significantly improves the quality of 3D reconstructions and enables more effective virtual hair design.

Conclusion

HairMapper provides a robust solution for hair removal in portraits by navigating the latent space of StyleGAN and employing a novel cross-domain training pipeline. While the method is currently dependent on the quality of the latent encoder (such as $e4e$), it represents a significant step forward in identity-preserving facial editing. Future work will explore more robust encoders and temporal consistency for video-based hair removal.

Summary updated

Abstract

Removing hair from portrait images is challenging due to the complex occlusions between hair and face, as well as the lack of paired portrait data with/without hair. To this end, we present a dataset and a baseline method for removing hair from portrait images using generative adversarial networks (GANs). Our core idea is to train a fully connected network HairMapper to find the direction of hair removal in the latent space of StyleGAN for the training stage. We develop a new separation boundary and diffuse method to generate paired training data for males, and a novel “female-male-bald” pipeline for paired data of females. Experiments show that our method can naturally deal with portrait images with variations on gender, age, etc. We validate the superior performance of our method by comparing it to state-of-the-art methods through extensive experiments and user studies. We also demonstrate its applications in hair design and 3D face reconstruction.
BibTeX
@misc{jin2022hairmapper,
  author = {Xiaogang Jin},
  title = {{HairMapper: Removing Hair from Portraits Using GANs}},
  year = {2022},
  url = {https://openreview.net/forum?id=G4TF35b7EHE},
  howpublished = {OpenReview},
}
Figure