Skip to content

Commit

Permalink
opencv detector is default
Browse files Browse the repository at this point in the history
  • Loading branch information
serengil committed Jun 23, 2021
1 parent 5090ac2 commit 8071733
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
10 changes: 5 additions & 5 deletions deepface/DeepFace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions deepface/commons/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]

Expand All @@ -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)
Expand Down

0 comments on commit 8071733

Please sign in to comment.