diff --git a/README.md b/README.md index 1ad80f3..7ab671f 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # deepface [![Downloads](https://pepy.tech/badge/deepface)](https://pepy.tech/project/deepface) +[![License](http://img.shields.io/:license-MIT-blue.svg?style=flat)](https://github.com/serengil/deepface/blob/master/LICENSE)

-**deepface** is a lightweight [face recognition](https://sefiks.com/2018/08/06/deep-face-recognition-with-keras/) and facial attribute analysis ([age](https://sefiks.com/2019/02/13/apparent-age-and-gender-prediction-in-keras/), [gender](https://sefiks.com/2019/02/13/apparent-age-and-gender-prediction-in-keras/), [emotion](https://sefiks.com/2018/01/01/facial-expression-recognition-with-keras/) and [race](https://sefiks.com/2019/11/11/race-and-ethnicity-prediction-in-keras/)) framework for python. You can apply facial analysis with just a few lines of code. It plans to bridge a gap between software engineering and machine learning studies. +**deepface** is a lightweight [face recognition](https://sefiks.com/2018/08/06/deep-face-recognition-with-keras/) and facial attribute analysis ([age](https://sefiks.com/2019/02/13/apparent-age-and-gender-prediction-in-keras/), [gender](https://sefiks.com/2019/02/13/apparent-age-and-gender-prediction-in-keras/), [emotion](https://sefiks.com/2018/01/01/facial-expression-recognition-with-keras/) and [race](https://sefiks.com/2019/11/11/race-and-ethnicity-prediction-in-keras/)) framework for python. It is a hybrid face recognition framework wrapping **state-of-the-art** models: [`VGG-Face`](https://sefiks.com/2018/08/06/deep-face-recognition-with-keras/) , [`Google FaceNet`](https://sefiks.com/2018/09/03/face-recognition-with-facenet-in-keras/), [`OpenFace`](https://sefiks.com/2019/07/21/face-recognition-with-openface-in-keras/), [`Facebook DeepFace`](https://sefiks.com/2020/02/17/face-recognition-with-facebook-deepface-in-keras/), [`DeepID`](https://sefiks.com/2020/06/16/face-recognition-with-deepid-in-keras/) and [`Dlib`](https://sefiks.com/2020/07/11/face-recognition-with-dlib-in-python/). ## Installation @@ -16,7 +17,7 @@ pip install deepface ## Face Recognition -A modern [**face recognition pipeline**](https://sefiks.com/2020/05/01/a-gentle-introduction-to-face-recognition-in-deep-learning/) consists of 4 common stages: [detect](https://sefiks.com/2020/02/23/face-alignment-for-face-recognition-in-python-within-opencv/), [align](https://sefiks.com/2020/02/23/face-alignment-for-face-recognition-in-python-within-opencv/), [represent](https://sefiks.com/2018/08/06/deep-face-recognition-with-keras/) and [verify](https://sefiks.com/2020/05/22/fine-tuning-the-threshold-in-face-recognition/). **DeepFace** handles all these common stages in the background. +A modern [**face recognition pipeline**](https://sefiks.com/2020/05/01/a-gentle-introduction-to-face-recognition-in-deep-learning/) consists of 4 common stages: [detect](https://sefiks.com/2020/08/25/deep-face-detection-with-opencv-in-python/), [align](https://sefiks.com/2020/02/23/face-alignment-for-face-recognition-in-python-within-opencv/), [represent](https://sefiks.com/2018/08/06/deep-face-recognition-with-keras/) and [verify](https://sefiks.com/2020/05/22/fine-tuning-the-threshold-in-face-recognition/). **deepface** handles all these common stages in the background. **Face Verification** - [`Demo`](https://youtu.be/KRCvkNCOphE) @@ -44,7 +45,7 @@ df = DeepFace.find(img_path = "img1.jpg", db_path = "C:/workspace/my_db")

-**Face recognition models** +**Face recognition models** - [`Demo`](https://youtu.be/i_MOwvhbLdI) Deepface is a hybrid face recognition package. It currently wraps the **state-of-the-art** face recognition models: [`VGG-Face`](https://sefiks.com/2018/08/06/deep-face-recognition-with-keras/) , [`Google FaceNet`](https://sefiks.com/2018/09/03/face-recognition-with-facenet-in-keras/), [`OpenFace`](https://sefiks.com/2019/07/21/face-recognition-with-openface-in-keras/), [`Facebook DeepFace`](https://sefiks.com/2020/02/17/face-recognition-with-facebook-deepface-in-keras/), [`DeepID`](https://sefiks.com/2020/06/16/face-recognition-with-deepid-in-keras/) and [`Dlib`](https://sefiks.com/2020/07/11/face-recognition-with-dlib-in-python/). The default configuration verifies faces with **VGG-Face** model. You can set the base model while verification as illustared below. @@ -54,7 +55,7 @@ for model in models: result = DeepFace.verify("img1.jpg", "img2.jpg", model_name = model) ``` -FaceNet and VGG-Face [overperforms](https://youtu.be/i_MOwvhbLdI) than OpenFace, DeepFace and DeepID based on experiments. +FaceNet, VGG-Face and Dlib [overperforms](https://youtu.be/i_MOwvhbLdI) than OpenFace, DeepFace and DeepID based on experiments. **Similarity** @@ -167,7 +168,7 @@ You can also read a translated version of deepface tutorials in [Chinese (深臉 Reference face recognition models have different type of licenses. This framework is just a wrapper for those models. That's why, licence types are inherited as well. You should check the licenses for the face recognition models before use. -Herein, [OpenFace](https://github.com/cmusatyalab/openface/blob/master/LICENSE) is licensed under Apache License 2.0. [FB DeepFace](https://github.com/swghosh/DeepFace) and [Facenet](https://github.com/davidsandberg/facenet/blob/master/LICENSE.md) is licensed under MIT License. The both Apache License 2.0 and MIT license types allow you to use for commercial purpose. +Herein, [OpenFace](https://github.com/cmusatyalab/openface/blob/master/LICENSE) is licensed under Apache License 2.0. [FB DeepFace](https://github.com/swghosh/DeepFace) and [Facenet](https://github.com/davidsandberg/facenet/blob/master/LICENSE.md) is licensed under MIT License. [Dlib](https://github.com/davisking/dlib/blob/master/dlib/LICENSE.txt) is licensed under Boost Software License. They all allow you to use for personal and commercial purpose free. On the other hand, [VGG-Face](http://www.robots.ox.ac.uk/~vgg/software/vgg_face/) is licensed under Creative Commons Attribution License. That's why, it is restricted to adopt VGG-Face for commercial use. diff --git a/deepface/basemodels/DeepID.py b/deepface/basemodels/DeepID.py index c31bb0e..30f67c1 100644 --- a/deepface/basemodels/DeepID.py +++ b/deepface/basemodels/DeepID.py @@ -8,7 +8,7 @@ import zipfile #------------------------------------- -def loadModel(): +def loadModel(url = 'https://drive.google.com/uc?id=1uRLtBCTQQAvHJ_KVrdbRJiCKxU8m5q2J'): myInput = Input(shape=(55, 47, 3)) @@ -43,7 +43,6 @@ def loadModel(): if os.path.isfile(home+'/.deepface/weights/deepid_keras_weights.h5') != True: print("deepid_keras_weights.h5 will be downloaded...") - url = 'https://drive.google.com/uc?id=1uRLtBCTQQAvHJ_KVrdbRJiCKxU8m5q2J' output = home+'/.deepface/weights/deepid_keras_weights.h5' gdown.download(url, output, quiet=False) diff --git a/deepface/basemodels/Facenet.py b/deepface/basemodels/Facenet.py index 8222191..7a63502 100644 --- a/deepface/basemodels/Facenet.py +++ b/deepface/basemodels/Facenet.py @@ -530,7 +530,7 @@ def InceptionResNetV2(): return model -def loadModel(): +def loadModel(url = 'https://drive.google.com/uc?id=1971Xk5RwedbudGgTIrGAL4F7Aifu7id1'): model = InceptionResNetV2() #----------------------------------- @@ -540,7 +540,6 @@ def loadModel(): if os.path.isfile(home+'/.deepface/weights/facenet_weights.h5') != True: print("facenet_weights.h5 will be downloaded...") - url = 'https://drive.google.com/uc?id=1971Xk5RwedbudGgTIrGAL4F7Aifu7id1' output = home+'/.deepface/weights/facenet_weights.h5' gdown.download(url, output, quiet=False) diff --git a/deepface/basemodels/FbDeepFace.py b/deepface/basemodels/FbDeepFace.py index 98c0485..6d130da 100644 --- a/deepface/basemodels/FbDeepFace.py +++ b/deepface/basemodels/FbDeepFace.py @@ -8,7 +8,7 @@ import zipfile #------------------------------------- -def loadModel(): +def loadModel(url = 'https://github.com/swghosh/DeepFace/releases/download/weights-vggface2-2d-aligned/VGGFace2_DeepFace_weights_val-0.9034.h5.zip'): base_model = Sequential() base_model.add(Convolution2D(32, (11, 11), activation='relu', name='C1', input_shape=(152, 152, 3))) base_model.add(MaxPooling2D(pool_size=3, strides=2, padding='same', name='M2')) @@ -28,8 +28,6 @@ def loadModel(): if os.path.isfile(home+'/.deepface/weights/VGGFace2_DeepFace_weights_val-0.9034.h5') != True: print("VGGFace2_DeepFace_weights_val-0.9034.h5 will be downloaded...") - url = 'https://github.com/swghosh/DeepFace/releases/download/weights-vggface2-2d-aligned/VGGFace2_DeepFace_weights_val-0.9034.h5.zip' - output = home+'/.deepface/weights/VGGFace2_DeepFace_weights_val-0.9034.h5.zip' gdown.download(url, output, quiet=False) diff --git a/deepface/basemodels/OpenFace.py b/deepface/basemodels/OpenFace.py index c2f3e71..82a4af9 100644 --- a/deepface/basemodels/OpenFace.py +++ b/deepface/basemodels/OpenFace.py @@ -15,7 +15,7 @@ from keras import backend as K #--------------------------------------- -def loadModel(): +def loadModel(url = 'https://drive.google.com/uc?id=1LSe1YCV1x-BfNnfb7DFZTNpv_Q9jITxn'): myInput = Input(shape=(96, 96, 3)) x = ZeroPadding2D(padding=(3, 3), input_shape=(96, 96, 3))(myInput) @@ -237,7 +237,6 @@ def loadModel(): if os.path.isfile(home+'/.deepface/weights/openface_weights.h5') != True: print("openface_weights.h5 will be downloaded...") - url = 'https://drive.google.com/uc?id=1LSe1YCV1x-BfNnfb7DFZTNpv_Q9jITxn' output = home+'/.deepface/weights/openface_weights.h5' gdown.download(url, output, quiet=False) diff --git a/deepface/basemodels/VGGFace.py b/deepface/basemodels/VGGFace.py index f354526..48d8495 100644 --- a/deepface/basemodels/VGGFace.py +++ b/deepface/basemodels/VGGFace.py @@ -54,7 +54,7 @@ def baseModel(): return model -def loadModel(): +def loadModel(url = 'https://drive.google.com/uc?id=1CPSeum3HpopfomUEK1gybeuIVoeJT_Eo'): model = baseModel() @@ -63,9 +63,8 @@ def loadModel(): home = str(Path.home()) if os.path.isfile(home+'/.deepface/weights/vgg_face_weights.h5') != True: - print("vgg_face_weights.h5 will be downloaded...") + print("vgg_face_weights.h5 will be downloaded...") - url = 'https://drive.google.com/uc?id=1CPSeum3HpopfomUEK1gybeuIVoeJT_Eo' output = home+'/.deepface/weights/vgg_face_weights.h5' gdown.download(url, output, quiet=False)