config_facenet.py 969 Bytes
Newer Older
1
import bob.bio.video as video
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
2
3
from bob.ip.tensorflow_extractor import FaceNet
from bob.bio.base.extractor import Extractor
4
from bob.bio.face.preprocessor import FaceCrop
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
5
from bob.bio.base.config.algorithm.distance_cosine import algorithm
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
6
sub_directory = 'facenet'
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
7
8
9
10
11
12
13
14
15

# This is the size of the image that this model expects
CROPPED_IMAGE_HEIGHT = 160
CROPPED_IMAGE_WIDTH = 160
# eye positions for frontal images
RIGHT_EYE_POS = (46, 53)
LEFT_EYE_POS = (46, 107)

# Detects the face and crops it with eye detection
16
17
18
19
preprocessor = FaceCrop(
    cropped_image_size=(CROPPED_IMAGE_HEIGHT, CROPPED_IMAGE_WIDTH),
    cropped_positions={'leye': LEFT_EYE_POS, 'reye': RIGHT_EYE_POS},
    color_channel='rgb',
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
20
21
22
23
24
25
26
)


class FaceNetExtractor(FaceNet, Extractor):
    pass


27
extractor = FaceNetExtractor(model_path='./20170512-110547')
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
28
29
30
31

preprocessor = video.preprocessor.Wrapper(preprocessor)
extractor = video.extractor.Wrapper(extractor)
algorithm = video.algorithm.Wrapper(algorithm)