-
Notifications
You must be signed in to change notification settings - Fork 0
/
FRmodel.py
35 lines (23 loc) · 892 Bytes
/
FRmodel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from tensorflow.keras import Input
from tensorflow.keras.models import Model
from tensorflow.keras.layers import concatenate
from model import build_model
from config import image_shape
def FRmodel():
base_model = build_model()
A = Input(shape=image_shape, name = 'anchors')
P = Input(shape=image_shape, name = 'positives')
N = Input(shape=image_shape, name = 'negatives')
enc_A = base_model(A)
enc_P = base_model(P)
enc_N = base_model(N)
output = concatenate([enc_A, enc_P, enc_N])
FRmodel = Model(inputs=[A, P, N], outputs=output)
return FRmodel
def get_faceRecoModel():
frmodel = FRmodel()
frmodel.load_weights('./model/best_model.h5')
inner_model_name = 'FaceRecoModel'
inner_model = frmodel.get_layer(inner_model_name)
model = Model(inputs=inner_model.input, outputs=inner_model.output)
return model