opencv detector is default

This commit is contained in:
Sefik Ilkin Serengil 2021-06-23 13:46:47 +03:00
parent 5090ac2f15
commit 8071733ddf
3 changed files with 8 additions and 8 deletions

View File

@ -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 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 ```python
backends = ['opencv', 'ssd', 'dlib', 'mtcnn', 'retinaface'] backends = ['opencv', 'ssd', 'dlib', 'mtcnn', 'retinaface']

View File

@ -59,7 +59,7 @@ def build_model(model_name):
else: else:
raise ValueError('Invalid model_name passed - {}'.format(model_name)) 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. 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 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 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 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 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 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. 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 realtime.analysis(db_path, model_name, distance_metric, enable_face_analysis
, source = source, time_threshold = time_threshold, frame_threshold = frame_threshold) , 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 This function applies pre-processing stages of a face recognition pipeline including detection and alignment

View File

@ -87,7 +87,7 @@ def load_image(img):
return 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]] 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: 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.") 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 might be path, base64 or numpy array. Convert it to numpy whatever it is.
img = load_image(img) img = load_image(img)