Skip to content

joelove/python-face-recognition

Repository files navigation

python-face-recognition

A real-time facial recognition tool built with Python

Prerequisites

Mac OS X comes with Python 2.7 out of the box. However, this project uses Python 3.7 so we'll install it using Homebrew:

brew install python

You'll probably need to augment your PATH in .bash_profile or .zshrc, too:

export PATH="/usr/local/opt/python/libexec/bin:$PATH"

If you're using Linux or Windows, you'll need to work this bit out yourself.

This project uses Poetry to manage packages and environments. Frankly, I couldn't find a viable alternative amongst the vast menagerie of whacky and incomplete Python package managers. PyPI is still terrible so packages aren't any easier to find but at least we won't need to fight with Pip and Virtualenv:

curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python

You still might need to install Pip and Virtualenv so Poetry can use them behind the scenes.

Installation

If you're running MacOS and the many malevolent gods of the Python ecosystem are smiling upon you today, you should just be able to install the dependencies using Poetry:

poetry install

Training the script

Before running the script, save a .jpg for each face you want to match in the faces directory. Training will happen automatically before the first run and the name of the file will be the identifier for that face.

/faces
├── john-doe.jpg
└── jenna-bloggs.jpg

If you want to retrain the script with new faces just delete faces/faces.npy:

rm faces/faces.npy

Running the script

If you're holding a lucky rabbit's foot and pigs have been flying in your little corner of the infinite multiverse since the emergence of the cosmos, you can just run:

poetry run python main.py

Credit

This tool is based on several different tools and is made possible in no small part by the hard work of engineers much more talented than myself, including but not limited to:


Sponsored

About

A real-time facial recognition tool built with Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages