From e14d7d6afc1c84dc055d519a06e3b2341a282522 Mon Sep 17 00:00:00 2001 From: Ronald Pereira Date: Thu, 26 Jan 2023 10:54:24 -0300 Subject: [PATCH] .represent model parameter was being ignored if built and passed to function call --- deepface/DeepFace.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/deepface/DeepFace.py b/deepface/DeepFace.py index 75346d4..2d0509e 100644 --- a/deepface/DeepFace.py +++ b/deepface/DeepFace.py @@ -502,10 +502,19 @@ def represent(img_path, model_name = 'VGG-Face', model = None, enforce_detection Parameters: img_path (string): exact image path. Alternatively, numpy array (BGR) or based64 encoded images could be passed. - enforce_detection (boolean): If any face could not be detected in an image, then verify function will return exception. Set this to False not to have this exception. This might be convenient for low resolution images. + model_name (string): VGG-Face, Facenet, Facenet512, OpenFace, DeepFace, DeepID, Dlib, ArcFace, SFace + + model: Built deepface model. A face recognition model is built every call of verify function. You can pass pre-built face recognition model optionally if you will call verify function several times. Consider to pass model if you are going to call represent function in a for loop. + + model = DeepFace.build_model('VGG-Face') + + enforce_detection (boolean): If no face could not be detected in an image, then this function will return exception by default. + Set this to False not to have this exception. This might be convenient for low resolution images. detector_backend (string): set face detector backend to opencv, retinaface, mtcnn, ssd, dlib or mediapipe + align (boolean): alignment according to the eye positions. + normalization (string): normalize the input image before feeding to model Returns: @@ -513,7 +522,8 @@ def represent(img_path, model_name = 'VGG-Face', model = None, enforce_detection """ resp_objs = [] - model = build_model(model_name) + if model is None: + model = build_model(model_name) #--------------------------------- # we started to run pre-process in verification. so, this can be skipped if it is coming from verification.