A million scale facial recognition system.
Facial Recognition Software system to store and index millions of face-fingerprints and search for matches.
It's recommended (but not necessary) to have an NVIDIA gpu with cuda libraries installed for face recognition to work reasonably fast
OS X & Linux:
pip3 install -r requirements.txt
Windows:
pip install -r requirements.txt
First, you can setup the database configuration files (or just keep the default configuration) in LSFR/core/FaceData/dbconfig.py and LSFR/core/LSH/dbconfig.py
Below example shows how to scrape an instagram profile to download all the images, store the face encodings and index them for easier search
from core.LSH.lsh import SQLDiskLSH
from core.main import set_credentials, initialize, add
# set your instagram credentials to scrape instagram profiles
set_credentials("instagram", "your-instagram-username", "your-instagram-password")
index = SQLDiskLSH()
# urls of profiles that you want to scrape
urls = [
"https://www.instagram.com/veritasium/?hl=en",
"https://www.instagram.com/thephysicsgirl/?hl=en",
]
# the add function will download every single image from the url and stores the face embeddings. If you run the add function on the same url again, then it will pickup where it left off (scrape any new images that were added after a while)
for url in urls:
add(index, url)
Now lets look at how to find matching faces
from core.mappers import default_sql_mapper
from core.main import initialize, query, get_faces
index = SQLDiskLSH()
faces = []
for data in get_faces("some_image_that_has_a_face.jpg"):
faces.append(data)
face_num, face_loc, face_embedding = faces[0]
# query function returns a list of matches where each match has information on the ID of face stored in database and the euclidean distance of the given face and the matched face (low distance = better match)
matches = query(index, default_sql_mapper, face_embedding, 20)
print(matches)
# you can use the IDs to query the FaceData database and get the link to the original post
M. Zahash โ [email protected]
Distributed under the MIT license. See LICENSE
for more information.
- Fork it (https://github.com/zahash/LSFR/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request