A simple wrapper for face feature detection and recognition.

Several personal projects I’ve had in the past relied on some basic face feature detection either for face isolation, face state detection, or some kinds of perspective estimation. I found that there are plenty of resources for learning how to perform face detection in Python, but most of them suffer from a handful of the following issues:

  1. Isn’t easy to use right out of the box.

  2. Doesn’t provide face feature detection, just simple face detection.

  3. Relies on older and no-longer maintained methods from cv2 for face detection.

  4. Is pretty greedy in terms of memory usage and scattered method calls.

  5. Doesn’t provide a selection of helpers to make face detection easier and quicker.

  6. Requires that you write a whole bunch of boilerplate to get anything clean looking.

  7. Or just my own personal disagreements with some of the code structure.

This project is my own attempt to provide decent face feature detection when you don’t want to think too hard about it. We try to get as close as possible to a single pip install and still provide effective detection and recognition in Python. However, we do have several system dependencies that are necessary, see System Requirements for more details.

Below is a simple example of full face feature detection and rendering out to a standard OpenCV window using some of the features available in Facelift. To get started using this package, please see the Getting Started guide.

from facelift import FullFaceDetector, iter_stream_frames
from facelift.render import draw_line
from facelift.window import opencv_window

detector = FullFaceDetector()
with opencv_window() as window:
    for frame in iter_stream_frames():
        for face in detector.iter_faces(frame):
            for feature, points in face.landmarks.items():
                frame = draw_line(frame, points)