File size: 1,135 Bytes
08b7b53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
from keras_vggface import VGGFace
from face_rec_reshape import face_rec_reshape 
import cv2
import numpy as np
import tensorflow as tf

model = VGGFace(model='resnet50', include_top=False, input_shape=(224, 224, 3), pooling='avg')
url = "./Abbie_test.jpg"
#url = "./Data/face_test.png"
Img = cv2.imread(url, 1)
List = face_rec_reshape(Img)
vect = model.predict(tf.expand_dims(List[0], axis=0))[0]
Data_set_vects = np.load('file.npy', allow_pickle='TRUE')
#Data_set_vects = np.load('file2.npy', allow_pickle='TRUE')
Data_set_vects = Data_set_vects.item()


def norme(V):
    S = 0
    for i in V:
        S += i**2
    return S**0.5

def distance(V1, V2):
    return norme(V2-V1)

min = 1000
p = ''

"""L = ['A.J._Buckley.txt', 'A.R._Rahman.txt', 'Aamir_Khan.txt', 'Aaron_Staton.txt', 
'Aaron_Tveit.txt', 'Aaron_Yoo.txt', 'Abbie_Cornish.txt', 'Abel_Ferrara.txt', 'Abigail_Breslin.txt',
'Abigail_Klein.txt']"""

for personne in Data_set_vects.keys():
    if distance(Data_set_vects[personne], vect)<min :
        min = distance(Data_set_vects[personne], vect)
        p = personne
print("it's : " + p[:len(p)-5])
#print("it's : " + p)