Skip to main content

Face Recognition

Simple library to recognize faces from given images

Face Recognition pipeline

Below the pipeline for face recognition:

  • Face Detection: the MTCNN algorithm is used to do face detection
  • Face Alignement Align face by eyes line
  • Face Encoding Extract encoding from face using FaceNet
  • Face Classification Classify face via eculidean distrances between face encodings

How to install

pip install git+https://github.com/paoloripamonti/face-recognition

How to train custom model

Initialize model

from face_recognition import FaceRecognition

fr = FaceRecognition()

Train model with pandas DataFrame:

fr = FaceRecognition()

fr.fit_from_dataframe(df)

where 'df' is pandas DataFrame with column person (person name) and column path (image path)

Train model with folder:

fr = FaceRecognition()

fr.fit('/path/root/')

the root folder must have the following structure:

root\
    Person_1\
        image.jpg
        ...
        image.jpg
    Person_2\
        image.jpg
        ...
        image.jpg
    ...
        

Save and load model

you can save and load model as pickle file.

fr.save('model.pkl')
fr = FaceRecognition()

fr.load('model.pkl')

Predict image

fr.predict('/path/image.jpg')

Recognize faces from given image. The output is a JSON with folling structure:

{
  "frame": "image data", # base64 image with bounding boxes
  "elapsed_time": time, # elapsed time in seconds
  "predictions": [
      {
        "person": "Person", # person name
        "confidence": float, # prediction confidence
        "box": (x1, y1, x2, y2) # face bounding box
      }
  ]
}

Example

For more details you can see: https://www.kaggle.com/paoloripamonti/face-recogniton

Download files

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

Source Distribution

facenet-face-recognition-0.1.tar.gz (5.5 kB view details)

Uploaded Source

File details

Details for the file facenet-face-recognition-0.1.tar.gz.

File metadata

  • Download URL: facenet-face-recognition-0.1.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.0

File hashes

Hashes for facenet-face-recognition-0.1.tar.gz
Algorithm Hash digest
SHA256 bf741943552be03b87acb8c15cc14d3ade4ca491a93de56981100a98d9e59398
MD5 3c63b36e1d03a6b375afbede7374dcbb
BLAKE2b-256 eb6066bbdea11f97e9d39c2df91d57c6b7ae4f748ccb95206d60a32722f0d550

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page