# 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.
```bash
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)
```bash
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](https://github.com/davidsandberg/facenet), and the journal article [here](https://arxiv.org/abs/1503.03832).
Raw data
{
"_id": null,
"home_page": "https://github.com/mattlyon93/face-comparison",
"name": "face-compare",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "ai,cv,computer-vision,face-detection",
"author": "Matt Lyon",
"author_email": "matthewlyon18@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/9d/b5/6e1f1b2f29763ad2c5fd7d5de6bde19e0a049ce5771134205fb5b73b1738/face-compare-1.1.4.tar.gz",
"platform": null,
"description": "# face-comparison\nAI Face comparison using FaceNet, compare two photos and see if they are the same person.\n\n## Installation\n```\npip install face-compare\n```\n\n## Usage\nUse `compare_faces.py` to compare two images of people to see if they are the same person.\n```bash\ncompare_faces.py --image-one /path/to/image_one.png --image-two /path/to/image_two.png\n```\n\nOptionally output the cropped image output to a directory (useful for inspecting input to AI model)\n```bash\ncompare_faces.py --image-one /path/to/image_one.png --image-two /path/to/image_two.png -s /path/to/outputs/\n```\n\n## Steps Involved\n1. A cascade classifier is used to detect the face within the input images.\n2. The bounding box of this segmentation is then used to crop the images, and fed into the AI model.\n3. The FaceNet model then calculates the image embeddings for the two cropped images.\n4. Finally the second embedding is subtracted from the first, and the Euclidean norm of that vector is calculated.\n5. A threshold of 0.7 is used to determine whether they are the same person or not.\n\n## Known Issues\n\n#### CPU Only runtime issue\nIf you are trying to run the module without a suitable GPU, you may run into the following error message:\n```\ntensorflow.python.framework.errors_impl.InvalidArgumentError: Default MaxPoolingOp only supports NHWC on device type CPU\n```\nTo fix this issue with Intel CPU architecture, you can install the TensorFlow Intel Optimization package via\n```\npip install intel-tensorflow\n```\n\n## References\nThis 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).\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Compare if two faces are from the same person.",
"version": "1.1.4",
"split_keywords": [
"ai",
"cv",
"computer-vision",
"face-detection"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "853771b70867f37f9fea54360480437f",
"sha256": "ea923cafc2cc8ca1c4a23594a299d5a4d3575f7bc5feceac216e133246bf2f74"
},
"downloads": -1,
"filename": "face_compare-1.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "853771b70867f37f9fea54360480437f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 13947562,
"upload_time": "2022-12-24T17:17:07",
"upload_time_iso_8601": "2022-12-24T17:17:07.829289Z",
"url": "https://files.pythonhosted.org/packages/a2/7f/d07c502e362ee57d73059fdddacd2784557769782b7cb7b4aa1f6d56f75c/face_compare-1.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "9dedf20bdd20bd5a4f01560d3868b1c1",
"sha256": "d497ebe79d71b34a06d68ee4559f6e6566567b74d80bf85ed1919c7a250d26b9"
},
"downloads": -1,
"filename": "face-compare-1.1.4.tar.gz",
"has_sig": false,
"md5_digest": "9dedf20bdd20bd5a4f01560d3868b1c1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 13947189,
"upload_time": "2022-12-24T17:17:10",
"upload_time_iso_8601": "2022-12-24T17:17:10.650343Z",
"url": "https://files.pythonhosted.org/packages/9d/b5/6e1f1b2f29763ad2c5fd7d5de6bde19e0a049ce5771134205fb5b73b1738/face-compare-1.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-24 17:17:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "mattlyon93",
"github_project": "face-comparison",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "face-compare"
}