deepid in api and stream

This commit is contained in:
Şefik Serangil 2020-06-17 09:05:34 +03:00
parent 5748a009b6
commit 4bb49ab446
2 changed files with 17 additions and 8 deletions

View File

@ -9,7 +9,7 @@ from tqdm import tqdm
import tensorflow as tf
from deepface import DeepFace
from deepface.basemodels import VGGFace, OpenFace, Facenet, FbDeepFace
from deepface.basemodels import VGGFace, OpenFace, Facenet, FbDeepFace, DeepID
from deepface.extendedmodels import Age, Gender, Race, Emotion
#import DeepFace
@ -26,7 +26,7 @@ tic = time.time()
print("Loading Face Recognition Models...")
pbar = tqdm(range(0,4), desc='Loading Face Recognition Models...')
pbar = tqdm(range(0,5), desc='Loading Face Recognition Models...')
for index in pbar:
if index == 0:
@ -41,6 +41,9 @@ for index in pbar:
elif index == 3:
pbar.set_description("Loading Facebook DeepFace")
deepface_model = FbDeepFace.loadModel()
elif index == 4:
pbar.set_description("Loading DeepID DeepFace")
deepid_model = DeepID.loadModel()
toc = time.time()
@ -195,6 +198,8 @@ def verify():
resp_obj = DeepFace.verify(instances, model_name = model_name, distance_metric = distance_metric, model = openface_model)
elif model_name == "DeepFace":
resp_obj = DeepFace.verify(instances, model_name = model_name, distance_metric = distance_metric, model = deepface_model)
elif model_name == "DeepID":
resp_obj = DeepFace.verify(instances, model_name = model_name, distance_metric = distance_metric, model = deepid_model)
elif model_name == "Ensemble":
models = {}
models["VGG-Face"] = vggface_model

View File

@ -9,11 +9,7 @@ import re
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
#from basemodels import VGGFace, OpenFace, Facenet, FbDeepFace
#from extendedmodels import Age, Gender, Race, Emotion
#from commons import functions, realtime, distance as dst
from deepface.basemodels import VGGFace, OpenFace, Facenet, FbDeepFace
from deepface.basemodels import VGGFace, OpenFace, Facenet, FbDeepFace, DeepID
from deepface.extendedmodels import Age, Gender, Race, Emotion
from deepface.commons import functions, realtime, distance as dst
@ -57,10 +53,18 @@ def analysis(db_path, model_name, distance_metric, enable_face_analysis = True):
model = FbDeepFace.loadModel()
input_shape = (152, 152)
elif model_name == 'DeepID':
print("Using DeepID model backend", distance_metric,"distance.")
model = DeepID.loadModel()
input_shape = (55, 47)
else:
raise ValueError("Invalid model_name passed - ", model_name)
#------------------------
input_shape_x = input_shape[0]
input_shape_y = input_shape[1]
#tuned thresholds for model and metric pair
threshold = functions.findThreshold(model_name, distance_metric)
@ -341,7 +345,7 @@ def analysis(db_path, model_name, distance_metric, enable_face_analysis = True):
#-------------------------------
#face recognition
custom_face = functions.detectFace(custom_face, input_shape)
custom_face = functions.detectFace(custom_face, (input_shape_y, input_shape_x))
#check detectFace function handled
if custom_face.shape[1:3] == input_shape: