-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,29 @@ | ||
# face-comparison | ||
AI Face comparison using FaceNet | ||
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. | ||
```bash | ||
compare_faces.py --input-one /path/to/image_one.png --input-two /path/to/image_two.png | ||
``` | ||
|
||
Optionally output the cropped image output to a directory (useful for inspecting input to AI model) | ||
```bash | ||
compare_faces.py --input-one /path/to/image_one.png --input-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. | ||
|
||
|
||
## References | ||
This module uses the AI model FaceNet, which can be found [here](https://github.com/davidsandberg/facenet), and the journal article [here](https://arxiv.org/abs/1503.03832). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
#!/usr/bin/env python3 | ||
'''Use this to install module''' | ||
from os import path | ||
from setuptools import setup, find_packages | ||
|
||
version = '1.0.0' | ||
this_dir = path.abspath(path.dirname(__file__)) | ||
with open(path.join(this_dir, 'README.md'), encoding='utf-8') as f: | ||
long_description = f.read() | ||
|
||
setup( | ||
name='face_compare', | ||
version='1.0.0', | ||
name='face-compare', | ||
version=version, | ||
description='Compare if two faces are from the same person.', | ||
author='Matt Lyon', | ||
author_email='[email protected]', | ||
url='https://github.com/mattlyon93/face-comparison', | ||
download_url='https://github.com/mattlyon93/face-comparison/archive/v{}.tar.gz'.format(version), | ||
long_description=long_description, | ||
long_description_content_type='text/markdown', | ||
python_requires='>=3.7', | ||
license='MIT License', | ||
packages=find_packages(), | ||
|
@@ -22,5 +32,6 @@ | |
'Operating System :: MacOS', | ||
], | ||
scripts=['bin/compare_faces.py'], | ||
keywords=['ai', 'cv', 'computer-vision', 'face-detection'], | ||
include_package_data=True | ||
) |