mirror of
https://github.com/serengil/deepface.git
synced 2025-07-22 09:50:00 +00:00
Revert "Revert "Analyze Pass Models""
This reverts commit 378417f7691a5240434389728a73ff66719274cd.
This commit is contained in:
parent
378417f769
commit
987c5782a0
@ -21,52 +21,6 @@ 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 analyze_init(models = []):
|
|
||||||
#---------------------------------
|
|
||||||
built_models = {}
|
|
||||||
#if a specific target is not passed, then find them all
|
|
||||||
if len(models) == 0:
|
|
||||||
models = ['emotion', 'age', 'gender', 'race']
|
|
||||||
|
|
||||||
print("Models to initialize: ", models)
|
|
||||||
|
|
||||||
#---------------------------------
|
|
||||||
|
|
||||||
if 'emotion' in models:
|
|
||||||
built_models['emotion'] = Emotion.loadModel()
|
|
||||||
|
|
||||||
if 'age' in models:
|
|
||||||
built_models['age'] = Age.loadModel()
|
|
||||||
|
|
||||||
if 'gender' in models:
|
|
||||||
built_models['gender'] = Gender.loadModel()
|
|
||||||
|
|
||||||
if 'race' in models:
|
|
||||||
built_models['race'] = Race.loadModel()
|
|
||||||
return built_models
|
|
||||||
|
|
||||||
|
|
||||||
def verify_init(model_name = 'VGG-Face'):
|
|
||||||
if model_name == 'VGG-Face':
|
|
||||||
print("Loading %s model" % model_name)
|
|
||||||
model = VGGFace.loadModel()
|
|
||||||
|
|
||||||
elif model_name == 'OpenFace':
|
|
||||||
print("Loading %s model" % model_name)
|
|
||||||
model = OpenFace.loadModel()
|
|
||||||
|
|
||||||
elif model_name == 'Facenet':
|
|
||||||
print("Loading %s model" % model_name)
|
|
||||||
model = Facenet.loadModel()
|
|
||||||
|
|
||||||
elif model_name == 'DeepFace':
|
|
||||||
print("Loading %s model" % model_name)
|
|
||||||
model = FbDeepFace.loadModel()
|
|
||||||
else:
|
|
||||||
raise ValueError("Invalid model_name passed - ", model_name)
|
|
||||||
return model
|
|
||||||
|
|
||||||
|
|
||||||
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):
|
||||||
|
|
||||||
@ -349,13 +303,16 @@ def analyze(img_path, actions= [], models= {}):
|
|||||||
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