mirror of
https://github.com/serengil/deepface.git
synced 2025-06-07 12:05:22 +00:00
Merge pull request #17 from uriafranko/uria-franko
passing already built models to analyze function as well
This commit is contained in:
commit
fc70aa0aad
1
Contributors.md
Normal file
1
Contributors.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
uriafranko
|
@ -20,6 +20,7 @@ from deepface.basemodels import VGGFace, OpenFace, Facenet, FbDeepFace
|
|||||||
from deepface.extendedmodels import Age, Gender, Race, Emotion
|
from deepface.extendedmodels import Age, Gender, Race, Emotion
|
||||||
from deepface.commons import functions, realtime, distance as dst
|
from deepface.commons import functions, realtime, distance as dst
|
||||||
|
|
||||||
|
|
||||||
def verify(img1_path, img2_path=''
|
def verify(img1_path, img2_path=''
|
||||||
, model_name ='VGG-Face', distance_metric = 'cosine', model = None):
|
, model_name ='VGG-Face', distance_metric = 'cosine', model = None):
|
||||||
|
|
||||||
@ -148,7 +149,8 @@ def verify(img1_path, img2_path=''
|
|||||||
return resp_obj
|
return resp_obj
|
||||||
#return resp_objects
|
#return resp_objects
|
||||||
|
|
||||||
def analyze(img_path, actions= []):
|
|
||||||
|
def analyze(img_path, actions= [], models= {}):
|
||||||
|
|
||||||
if type(img_path) == list:
|
if type(img_path) == list:
|
||||||
img_paths = img_path.copy()
|
img_paths = img_path.copy()
|
||||||
@ -168,16 +170,28 @@ def analyze(img_path, actions= []):
|
|||||||
#---------------------------------
|
#---------------------------------
|
||||||
|
|
||||||
if 'emotion' in actions:
|
if 'emotion' in actions:
|
||||||
emotion_model = Emotion.loadModel()
|
if 'emotion' in models:
|
||||||
|
emotion_model = models['emotion']
|
||||||
|
else:
|
||||||
|
emotion_model = Emotion.loadModel()
|
||||||
|
|
||||||
if 'age' in actions:
|
if 'age' in actions:
|
||||||
age_model = Age.loadModel()
|
if 'age' in models:
|
||||||
|
age_model = models['age']
|
||||||
|
else:
|
||||||
|
age_model = Age.loadModel()
|
||||||
|
|
||||||
if 'gender' in actions:
|
if 'gender' in actions:
|
||||||
gender_model = Gender.loadModel()
|
if 'gender' in models:
|
||||||
|
gender_model = models['gender']
|
||||||
|
else:
|
||||||
|
gender_model = Gender.loadModel()
|
||||||
|
|
||||||
if 'race' in actions:
|
if 'race' in actions:
|
||||||
race_model = Race.loadModel()
|
if 'race' in models:
|
||||||
|
race_model = models['race']
|
||||||
|
else:
|
||||||
|
race_model = Race.loadModel()
|
||||||
#---------------------------------
|
#---------------------------------
|
||||||
|
|
||||||
resp_objects = []
|
resp_objects = []
|
||||||
@ -289,13 +303,16 @@ def analyze(img_path, actions= []):
|
|||||||
return resp_obj
|
return resp_obj
|
||||||
#return resp_objects
|
#return resp_objects
|
||||||
|
|
||||||
|
|
||||||
def detectFace(img_path):
|
def detectFace(img_path):
|
||||||
img = functions.detectFace(img_path)[0] #detectFace returns (1, 224, 224, 3)
|
img = functions.detectFace(img_path)[0] #detectFace returns (1, 224, 224, 3)
|
||||||
return img[:, :, ::-1] #bgr to rgb
|
return img[:, :, ::-1] #bgr to rgb
|
||||||
|
|
||||||
|
|
||||||
def stream(db_path, model_name ='VGG-Face', distance_metric = 'cosine', enable_face_analysis = True):
|
def stream(db_path, model_name ='VGG-Face', distance_metric = 'cosine', enable_face_analysis = True):
|
||||||
realtime.analysis(db_path, model_name, distance_metric, enable_face_analysis)
|
realtime.analysis(db_path, model_name, distance_metric, enable_face_analysis)
|
||||||
|
|
||||||
|
|
||||||
#---------------------------
|
#---------------------------
|
||||||
|
|
||||||
functions.initializeFolder()
|
functions.initializeFolder()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user