Skip to main content

Deep Face Recognition Framework

Project description

deepface

deepface is a lightweight facial recognition framework. You can verify faces with just a few lines of codes.

from deepface import DeepFace
result = DeepFace.verify("img1.jpg", "img2.jpg")

Face recognition models

Face recognition can be handled by different models. Currently, VGG-Face , Facenet and OpenFace models are supported in deepface. The default configuration verifies faces with VGG-Face model. You can set the base model while verification as illustared below. Accuracy and speed show difference based on the performing model.

vggface_result = DeepFace.verify("img1.jpg", "img2.jpg")
#vggface_result = DeepFace.verify("img1.jpg", "img2.jpg", model_name = "VGG-Face")
facenet_result = DeepFace.verify("img1.jpg", "img2.jpg", model_name = "Facenet")
openface_result = DeepFace.verify("img1.jpg", "img2.jpg", model_name = "OpenFace")

Similarity

These models actually find the vector embeddings of faces. Decision of verification is based on the distance between vectors. Distance could be found by different metrics such as Cosine Similarity, Euclidean Distance and L2 form. The default configuration finds the cosine similarity. You can alternatively set the similarity metric while verification as demostratred below.

result = DeepFace.verify("img1.jpg", "img2.jpg", model_name = "VGG-Face", distance_metric = "cosine")
result = DeepFace.verify("img1.jpg", "img2.jpg", model_name = "VGG-Face", distance_metric = "euclidean")
result = DeepFace.verify("img1.jpg", "img2.jpg", model_name = "VGG-Face", distance_metric = "euclidean_l2")

Verification

Verification function returns a tuple including boolean verification result, distance between two faces and max threshold to identify.

(True, 0.281734, 0.30)

You can just check the verification result to decide that two images are same person or not. Thresholds for distance metrics are already tuned in the framework for face recognition models and distance metrics.

verified = result[0] #returns True if images are same person's face

Instead of using pre-tuned threshold values, you can alternatively check the distance by yourself.

distance = result[1] #the less the better

threshold = 0.30 #threshold for VGG-Face and Cosine Similarity

if distance < threshold:
	return True
else:
	return False

Installation

The easiest way to install deepface is to download it from PyPI.

pip install deepface

Alternatively, you can directly download the source code from this repository. GitHub repo might be newer than the PyPI version.

git clone https://github.com/serengil/chefboost.git
cd chefboost
pip install -e .

Initial tests are run for Python 3.5.5 on Windows 10 but this is an OS-independent framework. Even though pip handles to install dependent libraries, the framework basically needs the following dependencies. You might need the following library requirements if you install the source code from github.

pip install numpy==1.14.0
pip install matplotlib==2.2.2
pip install gdown==3.10.1
pip install opencv-python==3.4.4
pip install tensorflow==1.9.0
pip install keras==2.2.0

Support

There are many ways to support a project - starring⭐️ the GitHub repos is just one.

Licence

Chefboost is licensed under the MIT License - see LICENSE for more details.

Project details


Release history Release notifications | RSS feed

This version

0.0.1

Download files

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

Source Distribution

deepface-0.0.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

deepface-0.0.1-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file deepface-0.0.1.tar.gz.

File metadata

  • Download URL: deepface-0.0.1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.4

File hashes

Hashes for deepface-0.0.1.tar.gz
Algorithm Hash digest
SHA256 27ef595376313cb5df3048142f9ae24ab25c4605b1f72f36f43e52bfce50a9c5
MD5 8c6a13dfe25f9e6d853d8c244b155acf
BLAKE2b-256 4c34f84ca8fd8258df3c4672c6abc97ad3f53d3cb5d5f5f0fb3d7c800c773c31

See more details on using hashes here.

File details

Details for the file deepface-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: deepface-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.4

File hashes

Hashes for deepface-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12618720959797285e35926878bbc4e81c93cfb278e1aa7d7c7fb4af1d951895
MD5 edf973b91c9b892e89ab20eda2f7ed4f
BLAKE2b-256 37300da9f64088a59fdcfb187866b961c7cf9fb60ae96691e2f5bd24d7d9af8a

See more details on using hashes here.

Supported by

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