Face Parsing using BiSeNet for Real-time Semantic Segmentation
BiSeNet (Bilateral Segmentation Network) is a state-of-the-art model for real-time semantic segmentation, initially proposed in the paper Bilateral Segmentation Network for Real-time Semantic Segmentation. The architecture addresses the fundamental challenge in semantic segmentation: achieving high accuracy while maintaining real-time performance.
Architecture Overview
BiSeNet combines two complementary paths to balance spatial detail and semantic context:
- Spatial Path: Preserves high-resolution spatial information through a shallow network with wide channels, capturing fine-grained details essential for precise segmentation boundaries.
- Context Path: Employs a lightweight backbone to aggregate rich contextual information with a large receptive field, enabling accurate semantic understanding.
The fusion of these paths through a Feature Fusion Module ensures high segmentation accuracy with low computational cost, making it ideal for applications requiring real-time performance on resource-constrained devices.
Key Features
- Accurate Facial Parsing: Segments detailed facial features including eyes, nose, mouth, and hair for precise analysis
- ONNX Support: Seamless conversion from PyTorch to ONNX format for cross-platform deployment
- Flexible Backbones: Support for ResNet18 and ResNet34, allowing trade-offs between speed and accuracy
- Production-Ready: Optimized for real-time applications in AR/VR, digital makeup, and facial analysis systems
Performance Comparison
ResNet34 Backbone
ResNet18 Backbone
Getting Started
Clone the repository and install dependencies:
git clone https://github.com/yakhyo/face-parsing.git
cd face-parsing
pip install -r requirements.txt
Pre-trained weights are available for download:
Use Cases
This implementation is particularly useful for:
- Digital Makeup Applications: Precise facial feature segmentation for virtual makeup try-on
- Face Swapping: Accurate face region extraction for deepfake and face replacement systems
- Facial Analysis: Detailed feature extraction for emotion recognition and facial attribute analysis
- AR/VR Applications: Real-time face parsing for augmented reality filters and effects
Visit the GitHub repository for detailed documentation, training scripts, and inference examples.