face-recognition is a Python library that provides a straightforward API for facial detection, facial landmark localization, and face recognition from images and video. It leverages dlib's state-of-the-art deep learning models for high accuracy and offers both Python module and command-line interfaces. The current version is 1.3.0, and releases occur periodically to add features, improve performance, and address compatibility issues, often tied to its core dependency, dlib.
pip install face-recognitionVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to load an image and find all faces within it, returning their bounding box coordinates. It also shows how to locate key facial features (landmarks) like eyes, nose, and mouth. Ensure you have an image file named `my_picture.jpg` in the same directory as your script, or update the path accordingly.
Before `pip install face-recognition`, ensure CMake is installed and in your system PATH, and that C++ development tools are properly set up for your OS. It's often recommended to `pip install cmake` and `pip install dlib` separately before `pip install face-recognition`. Consider using a virtual environment.
Consider using Python 3.9 or 3.10 if encountering persistent build errors. Alternatively, try installing a pre-compiled `dlib` wheel (`.whl` file) compatible with your Python version and OS before installing `face-recognition`.
For cloud deployments, consider using a Docker image with pre-compiled `dlib` and `face-recognition`, or a `dlib-bin` package (if available) as a dependency. Some users have found success by forking the repository and replacing the `dlib` dependency with `dlib-bin` in `setup.py`.
Be aware of this limitation when applying the library to datasets containing children. Custom training or fine-tuning on child-specific datasets would be required for better performance, but this is beyond the scope of this library's direct functionality.