A face segmentation implementation of FarRL model (CVPR 2022) using Facer, a face analysis toolkit for modern research.
The author of FaRL performed pre-training on LAION-FACE, a dataset containing a large amount of face image-text pairs. They then used the pretrained encoder, to extract the image features for training a downstream task, which also includes Face Parsing task. In this work, I utilize the FaRL model which was pretrained on the Face Parsing task, and then map the predicted labels (eyes, nose, mouth, etc.) into two separate labels, i.e., face and background.
conda create --name {name_env} python==3.8
conda activate {name_env}
pip install git+https://github.com/FacePerceiver/facer.git@main
pip install timm
pip install imutils
python face_segmentation.py --image_path sample/Shin-Eun-Soo.jpg
To display the list of available arguments:
python face_segmentation.py --help
For left to right: segmented face image, extracted face mask, cropped face