Spaces:
Runtime error
Runtime error
| 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) | |