forked from sicxu/Deep3dPortrait
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathface_parsing.py
24 lines (19 loc) · 854 Bytes
/
face_parsing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import numpy as np
from scipy.io import loadmat
#######################################################################################
# Auxiliary functions for face segmentation
# for face parsing, please refer to https://arxiv.org/pdf/1906.01342.pdf
#######################################################################################
def faceparsing():
# return a label with 5 classes:
# 0: bg 1: face 2: hair 3: left ear 4: right ear 5(optional): inner mouth
return NotImplemented
def split_segmask(mask):
face_mask, hairear_mask, mouth_mask = np.zeros_like(mask), np.zeros_like(mask), np.zeros_like(mask)
face_mask[mask==1] = 1
face_mask[mask==5] = 1
hairear_mask[mask==2] = 1
hairear_mask[mask==3] = 1
hairear_mask[mask==4] = 1
mouth_mask[mask==5] = 1
return face_mask, hairear_mask, mouth_mask