From 8071733ddfc8aed8397c2a217f6624cb66d80c41 Mon Sep 17 00:00:00 2001 From: Sefik Ilkin Serengil Date: Wed, 23 Jun 2021 13:46:47 +0300 Subject: [PATCH] opencv detector is default --- README.md | 2 +- deepface/DeepFace.py | 10 +++++----- deepface/commons/functions.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2f9a958..910324f 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ The both face recognition and facial attribute analysis are covered in the API. **Face Detectors** - [`Demo`](https://youtu.be/GZ2p2hj2H5k) -Face detection and alignment are early stages of a modern face recognition pipeline. [`OpenCV`](https://sefiks.com/2020/02/23/face-alignment-for-face-recognition-in-python-within-opencv/), [`SSD`](https://sefiks.com/2020/08/25/deep-face-detection-with-opencv-in-python/), [`Dlib`](https://sefiks.com/2020/07/11/face-recognition-with-dlib-in-python/), [`MTCNN`](https://sefiks.com/2020/09/09/deep-face-detection-with-mtcnn-in-python/) and [`RetinaFace`](https://sefiks.com/2021/04/27/deep-face-detection-with-retinaface-in-python/) methods are wrapped in deepface as a facial detector. You can optionally pass a custom detector to functions in deepface interface. RetinaFace is the default detector if you won't pass any detector. +Face detection and alignment are early stages of a modern face recognition pipeline. [`OpenCV`](https://sefiks.com/2020/02/23/face-alignment-for-face-recognition-in-python-within-opencv/), [`SSD`](https://sefiks.com/2020/08/25/deep-face-detection-with-opencv-in-python/), [`Dlib`](https://sefiks.com/2020/07/11/face-recognition-with-dlib-in-python/), [`MTCNN`](https://sefiks.com/2020/09/09/deep-face-detection-with-mtcnn-in-python/) and [`RetinaFace`](https://sefiks.com/2021/04/27/deep-face-detection-with-retinaface-in-python/) methods are wrapped in deepface as a facial detector. You can optionally pass a custom detector to functions in deepface interface. OpenCV is the default detector if you won't pass any detector. ```python backends = ['opencv', 'ssd', 'dlib', 'mtcnn', 'retinaface'] diff --git a/deepface/DeepFace.py b/deepface/DeepFace.py index 1f7662d..32f79a8 100644 --- a/deepface/DeepFace.py +++ b/deepface/DeepFace.py @@ -59,7 +59,7 @@ def build_model(model_name): else: raise ValueError('Invalid model_name passed - {}'.format(model_name)) -def verify(img1_path, img2_path = '', model_name = 'VGG-Face', distance_metric = 'cosine', model = None, enforce_detection = True, detector_backend = 'retinaface', align = True): +def verify(img1_path, img2_path = '', model_name = 'VGG-Face', distance_metric = 'cosine', model = None, enforce_detection = True, detector_backend = 'opencv', align = True): """ This function verifies an image pair is same person or different persons. @@ -253,7 +253,7 @@ def verify(img1_path, img2_path = '', model_name = 'VGG-Face', distance_metric = return resp_obj -def analyze(img_path, actions = ['emotion', 'age', 'gender', 'race'] , models = {}, enforce_detection = True, detector_backend = 'retinaface'): +def analyze(img_path, actions = ['emotion', 'age', 'gender', 'race'] , models = {}, enforce_detection = True, detector_backend = 'opencv'): """ This function analyzes facial attributes including age, gender, emotion and race @@ -460,7 +460,7 @@ def analyze(img_path, actions = ['emotion', 'age', 'gender', 'race'] , models = return resp_obj -def find(img_path, db_path, model_name ='VGG-Face', distance_metric = 'cosine', model = None, enforce_detection = True, detector_backend = 'retinaface', align = True): +def find(img_path, db_path, model_name ='VGG-Face', distance_metric = 'cosine', model = None, enforce_detection = True, detector_backend = 'opencv', align = True): """ This function applies verification several times and find an identity in a database @@ -705,7 +705,7 @@ def find(img_path, db_path, model_name ='VGG-Face', distance_metric = 'cosine', return None -def represent(img_path, model_name = 'VGG-Face', model = None, enforce_detection = True, detector_backend = 'retinaface', align = True): +def represent(img_path, model_name = 'VGG-Face', model = None, enforce_detection = True, detector_backend = 'opencv', align = True): """ This function represents facial images as vectors. @@ -782,7 +782,7 @@ def stream(db_path = '', model_name ='VGG-Face', distance_metric = 'cosine', ena realtime.analysis(db_path, model_name, distance_metric, enable_face_analysis , source = source, time_threshold = time_threshold, frame_threshold = frame_threshold) -def detectFace(img_path, detector_backend = 'retinaface', enforce_detection = True): +def detectFace(img_path, detector_backend = 'opencv', enforce_detection = True): """ This function applies pre-processing stages of a face recognition pipeline including detection and alignment diff --git a/deepface/commons/functions.py b/deepface/commons/functions.py index 0f1f1f7..39eab5d 100644 --- a/deepface/commons/functions.py +++ b/deepface/commons/functions.py @@ -87,7 +87,7 @@ def load_image(img): return img -def detect_face(img, detector_backend = 'retinaface', grayscale = False, enforce_detection = True, align = True): +def detect_face(img, detector_backend = 'opencv', grayscale = False, enforce_detection = True, align = True): img_region = [0, 0, img.shape[0], img.shape[1]] @@ -106,7 +106,7 @@ def detect_face(img, detector_backend = 'retinaface', grayscale = False, enforce else: raise ValueError("Face could not be detected. Please confirm that the picture is a face photo or consider to set enforce_detection param to False.") -def preprocess_face(img, target_size=(224, 224), grayscale = False, enforce_detection = True, detector_backend = 'retinaface', return_region = False, align = True): +def preprocess_face(img, target_size=(224, 224), grayscale = False, enforce_detection = True, detector_backend = 'opencv', return_region = False, align = True): #img might be path, base64 or numpy array. Convert it to numpy whatever it is. img = load_image(img)