Skip to content

Commit

Permalink
Merge branch 'master' into fixyunet
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthraX1 committed Jul 14, 2023
2 parents 3e7f6df + 1321435 commit fc09756
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ Age model got ± 4.65 MAE; gender model got 97.44% accuracy, 96.29% precision an

Face detection and alignment are important early stages of a modern face recognition pipeline. Experiments show that just alignment increases the face recognition accuracy almost 1%. [`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/), [`RetinaFace`](https://sefiks.com/2021/04/27/deep-face-detection-with-retinaface-in-python/), [`MediaPipe`](https://sefiks.com/2022/01/14/deep-face-detection-with-mediapipe/), [`YOLOv8 Face`](https://github.com/derronqi/yolov8-face) and [`YuNet`](https://github.com/ShiqiYu/libfacedetection) detectors are wrapped in deepface.

<p align="center"><img src="https://raw.githubusercontent.com/serengil/deepface/master/icon/detector-portfolio-v3.jpg" width="95%" height="95%"></p>
<p align="center"><img src="https://raw.githubusercontent.com/serengil/deepface/master/icon/detector-portfolio-v5.jpg" width="95%" height="95%"></p>

All deepface functions accept an optional detector backend input argument. You can switch among those detectors with this argument. OpenCV is the default detector.

Expand Down
13 changes: 7 additions & 6 deletions deepface/detectors/YunetWrapper.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import cv2
import os
import cv2
import gdown
from deepface.detectors import FaceDetector
from deepface.commons import functions


def build_model():
url = "https://github.com/opencv/opencv_zoo/raw/main/models/face_detection_yunet/face_detection_yunet_2023mar.onnx"
url = (
"https://github.com/opencv/opencv_zoo/raw/main/models/"
+ "face_detection_yunet/face_detection_yunet_2023mar.onnx"
)
file_name = "face_detection_yunet_2023mar.onnx"
home = functions.get_deepface_home()
if os.path.isfile(home + f"/.deepface/weights/{file_name}") is False:
print(f"{file_name} will be downloaded...")
output = home + f"/.deepface/weights/{file_name}"
gdown.download(url, output, quiet=False)
face_detector = cv2.FaceDetectorYN_create(
home + f"/.deepface/weights/{file_name}", "", (0, 0)
)
face_detector = cv2.FaceDetectorYN_create(home + f"/.deepface/weights/{file_name}", "", (0, 0))
return face_detector


Expand Down Expand Up @@ -72,7 +73,7 @@ def detect_face(detector, image, align=True, score_threshold=0.9):
int(y_le / r),
)
confidence = face[-1]
confidence = "{:.2f}".format(confidence)
confidence = f"{confidence:.2f}"
detected_face = image[int(y) : int(y + h), int(x) : int(x + w)]
img_region = [x, y, w, h]
if align:
Expand Down
Binary file added icon/detector-portfolio-v5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fc09756

Please sign in to comment.