mirror of
https://github.com/serengil/deepface.git
synced 2025-06-06 19:45:21 +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.commons import functions, realtime, distance as dst
|
||||
|
||||
|
||||
def verify(img1_path, img2_path=''
|
||||
, model_name ='VGG-Face', distance_metric = 'cosine', model = None):
|
||||
|
||||
@ -148,7 +149,8 @@ def verify(img1_path, img2_path=''
|
||||
return resp_obj
|
||||
#return resp_objects
|
||||
|
||||
def analyze(img_path, actions= []):
|
||||
|
||||
def analyze(img_path, actions= [], models= {}):
|
||||
|
||||
if type(img_path) == list:
|
||||
img_paths = img_path.copy()
|
||||
@ -168,16 +170,28 @@ def analyze(img_path, 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:
|
||||
age_model = Age.loadModel()
|
||||
if 'age' in models:
|
||||
age_model = models['age']
|
||||
else:
|
||||
age_model = Age.loadModel()
|
||||
|
||||
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:
|
||||
race_model = Race.loadModel()
|
||||
if 'race' in models:
|
||||
race_model = models['race']
|
||||
else:
|
||||
race_model = Race.loadModel()
|
||||
#---------------------------------
|
||||
|
||||
resp_objects = []
|
||||
@ -289,13 +303,16 @@ def analyze(img_path, actions= []):
|
||||
return resp_obj
|
||||
#return resp_objects
|
||||
|
||||
|
||||
def detectFace(img_path):
|
||||
img = functions.detectFace(img_path)[0] #detectFace returns (1, 224, 224, 3)
|
||||
return img[:, :, ::-1] #bgr to rgb
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
#---------------------------
|
||||
|
||||
functions.initializeFolder()
|
||||
|
Loading…
x
Reference in New Issue
Block a user