Skip to main content

Compare if two faces are from the same person.

Project description

face-comparison

AI Face comparison using FaceNet, compare two photos and see if they are the same person.

Installation

pip install face-compare

Usage

Use compare_faces.py to compare two images of people to see if they are the same person.

compare_faces.py --image-one /path/to/image_one.png --image-two /path/to/image_two.png

Optionally output the cropped image output to a directory (useful for inspecting input to AI model)

compare_faces.py --image-one /path/to/image_one.png --image-two /path/to/image_two.png -s /path/to/outputs/

Steps Involved

  1. A cascade classifier is used to detect the face within the input images.
  2. The bounding box of this segmentation is then used to crop the images, and fed into the AI model.
  3. The FaceNet model then calculates the image embeddings for the two cropped images.
  4. Finally the second embedding is subtracted from the first, and the Euclidean norm of that vector is calculated.
  5. A threshold of 0.7 is used to determine whether they are the same person or not.

Known Issues

CPU Only runtime issue

If you are trying to run the module without a suitable GPU, you may run into the following error message:

tensorflow.python.framework.errors_impl.InvalidArgumentError:  Default MaxPoolingOp only supports NHWC on device type CPU

To fix this issue with Intel CPU architecture, you can install the TensorFlow Intel Optimization package via

pip install intel-tensorflow

References

This module uses the AI model FaceNet, which can be found here, and the journal article here.

Project details


Download files

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

Source Distribution

face-compare-1.1.1.tar.gz (13.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

face_compare-1.1.1-py3-none-any.whl (13.9 MB view details)

Uploaded Python 3

File details

Details for the file face-compare-1.1.1.tar.gz.

File metadata

  • Download URL: face-compare-1.1.1.tar.gz
  • Upload date:
  • Size: 13.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for face-compare-1.1.1.tar.gz
Algorithm Hash digest
SHA256 f881edb0b665d1136edf1e05917a1647c350d3b47c33053286fe58c8a7fcb783
MD5 2d188da4a536e782e6cba7297cf1f164
BLAKE2b-256 4dd7e82aa20c6fd00ba119f06114349a432aa5b8cfad05cb51ef0d6a00b762ce

See more details on using hashes here.

File details

Details for the file face_compare-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: face_compare-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for face_compare-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a21a456285ac14254b147a0dff4f7ed68287d156d24c618f2f1bfd58120f665
MD5 1e9c7e70b140683d239ecca56081beac
BLAKE2b-256 8ce0871b740ed73abc8fd8367e077f030d154ff1719d4c0600aabcce6530ccff

See more details on using hashes here.

Supported by

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