Tip
The models and functionality in this repository are integrated into UniFace — an all-in-one face analysis library.
Face segmentation using XSeg model from DeepFaceLab with UniFace for face detection and alignment. Automatically detects faces and generates pixel-accurate segmentation masks.
pip install -r requirements.txtDownload the pre-trained XSeg ONNX model:
| Model | Size | Download |
|---|---|---|
| XSeg | 70 MB | xseg.onnx |
Place the downloaded model in the weights/ directory.
python main.py --model weights/xseg.onnx --image assets/einstien.pngOptions:
| Argument | Default | Description |
|---|---|---|
--model |
required | Path to XSeg ONNX model |
--image |
assets/einstien.png |
Input image path |
--output |
None |
Output image path |
--blur |
0 |
Gaussian blur sigma for mask smoothing |
--align-size |
256 |
Face alignment size |
The script generates:
*_xseg_result.png- Image with mask overlay*_xseg_mask.png- Binary segmentation mask*_xseg_comparison.png- Side-by-side comparison*_aligned_crop.png- Aligned face crop
- UniFace - Face detection and alignment
- XSeg ONNX Model - Face Segmentation model used in DeepFaceLab
