Face parsing segments a face into semantic regions such as skin, hair, eyes, eyebrows, nose, mouth, and background. This repository implements BiSeNet for face parsing with ResNet18 and ResNet34 backbones. See the project on github.com/yakhyo/face-parsing.

Face parsing slideshow

The model is trained for facial component segmentation, not general scene segmentation. That makes it useful for virtual makeup, AR filters, face editing, matting workflows, and feature-level face analysis.

Example Results

Input Images

Original face image sample 1 Original face image sample 2 Original face image sample 3 Original face image sample 4

ResNet34 Results

ResNet34 face parsing result for sample 1 ResNet34 face parsing result for sample 2 ResNet34 face parsing result for sample 3 ResNet34 face parsing result for sample 4

ResNet18 Results

ResNet18 face parsing result for sample 1 ResNet18 face parsing result for sample 2 ResNet18 face parsing result for sample 3 ResNet18 face parsing result for sample 4

Models

Model Parameters Size
ResNet18 ~11.2M ~43 MB
ResNet34 ~21.3M ~82 MB

The model is trained on CelebAMask-HQ, a face parsing dataset with 30,000 images.

What the Repository Contains

The repository includes training code, PyTorch inference, ONNX export, and ONNX inference. Released weights are available for both ResNet18 and ResNet34 in PyTorch and ONNX formats.

Model PyTorch ONNX
ResNet18 yes yes
ResNet34 yes yes

The inference code accepts either a single image or a folder of images, which is useful when comparing parser output across a small validation set.

Why Face Parsing Matters

Face detection gives a bounding box. Landmarks give sparse points. Face parsing gives a dense semantic mask.

That mask can separate regions such as hair, skin, eyes, eyebrows, nose, lips, and background. This makes parsing useful for:

  • virtual makeup and face filters
  • face editing and compositing
  • portrait preprocessing
  • attribute and expression analysis
  • region-specific masking before downstream models

For application code, this model family is also available through UniFace.