Skip to main content

Face Recognition Tools

Project description

new_face

new_face repository includes face detection, face landmark, face alignment, and face recognition technique.


Installation

pip install -r requirements

or

pip install new_face

Face Detection

import logging
import cv2
import imutils
from new_face import FaceDetection

# Set logging config.
FORMAT = '%(asctime)s [%(levelname)s] %(message)s'
DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
logging.basicConfig(level=logging.INFO, format=FORMAT, datefmt=DATE_FORMAT)


image = cv2.imread("images/people.jpg")
resize_image = imutils.resize(image, width=1280)

face_detect = FaceDetection()
mtcnn = face_detect.load_detector(face_detect.MTCNN)

rois, raw_image, face_images = face_detect.mtcnn_detect(mtcnn,
                                                        resize_image,
                                                        conf_threshold=0.5,
                                                        vision=True,
                                                        save_path="images/mtcnn.jpg")

images/mtcnn.jpg images/mtcnn-2.jpg

source 1 source 2


Face Landmark

import logging
import cv2
import imutils
from new_face import FaceLandmark

# Set logging config.
FORMAT = '%(asctime)s [%(levelname)s] %(message)s'
DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
logging.basicConfig(level=logging.INFO, format=FORMAT, datefmt=DATE_FORMAT)


image = cv2.imread("images/people-3.jpg")
resize_image = imutils.resize(image, width=1280)

shape_5_predictor = FaceLandmark.load_shape_predictor("shape_predictor_5_face_landmarks.dat")
# shape_68_predictor = FaceLandmark.load_shape_predictor("shape_predictor_68_face_landmarks.dat")

face_points = FaceLandmark.dlib_5_points(image=resize_image,
                                        shape_predictor=shape_5_predictor,
                                        vision=True,
                                        save_path="images/dlib_5_points.jpg")

# face_points = FaceLandmark.dlib_68_points(image=resize_image,
#                                           shape_predictor=shape_68_predictor,
#                                           vision=True,
#                                           save_path="images/dlib_68_points.jpg")

images/dlib_5_points.jpg images/dlib_68_points.jpg

source


Face Alignment

import logging
import cv2
import imutils
from new_face import FaceAlignment

# Set logging config.
FORMAT = '%(asctime)s [%(levelname)s] %(message)s'
DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
logging.basicConfig(level=logging.INFO, format=FORMAT, datefmt=DATE_FORMAT)


image = cv2.imread("images/people-2.jpg")
resize_image = imutils.resize(image, width=1280)

face_alignment = FaceAlignment()
# detector, face_aligner = face_alignment.load_detector(face_alignment.DLIB)
mtcnn_detector = face_alignment.load_detector(face_alignment.MTCNN)

# rois, raw_image, align_images = face_alignment.dlib_alignment(detector,
#                                                               face_aligner,
#                                                               resize_image,
#                                                               vision=True,
#                                                               save_dir="images/align",
#                                                               face_size=256)

rois, raw_image, face_images = face_alignment.mtcnn_alignment(mtcnn_detector,
                                                            resize_image,
                                                            conf_threshold=0.9,
                                                            vision=True,
                                                            save_dir="images/align",
                                                            face_size=256)

images\people-2.jpg

images\align\000001.jpg images\align\000002.jpg images\align\000003.jpg images\align\000004.jpg images\align\000005.jpg images\align\000006.jpg images\align\000007.jpg images\align\000008.jpg images\align\000009.jpg images\align\000010.jpg images\align\000011.jpg images\align\000012.jpg images\align\000013.jpg images\align\000014.jpg images\align\000015.jpg images\align\000016.jpg images\align\000017.jpg images\align\000018.jpg

source


Reference

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

new_face-0.0.4.tar.gz (16.5 kB view hashes)

Uploaded Source

Built Distribution

new_face-0.0.4-py3-none-any.whl (25.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page