deepface | Lightweight Face Recognition and Facial Attribute Analysis | Computer Vision library

 by   serengil Python Version: 0.0.92 License: MIT

kandi X-RAY | deepface Summary

kandi X-RAY | deepface Summary

deepface is a Python library typically used in Artificial Intelligence, Computer Vision, Deep Learning, Tensorflow, Keras applications. deepface has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can install using 'pip install deepface' or download it from GitHub, PyPI.

Deepface is a lightweight face recognition and facial attribute analysis (age, gender, emotion and race) framework for python. It is a hybrid face recognition framework wrapping state-of-the-art models: VGG-Face, Google FaceNet, OpenFace, Facebook DeepFace, DeepID, ArcFace and Dlib. Those models already reached and passed the human level accuracy. The library is mainly based on TensorFlow and Keras.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              deepface has a medium active ecosystem.
              It has 6607 star(s) with 1367 fork(s). There are 103 watchers for this library.
              There were 1 major release(s) in the last 6 months.
              There are 10 open issues and 693 have been closed. On average issues are closed in 0 days. There are 4 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of deepface is 0.0.92

            kandi-Quality Quality

              deepface has 0 bugs and 0 code smells.

            kandi-Security Security

              deepface has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              deepface code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              deepface is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              deepface releases are not available. You will need to build from source code and install.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              Installation instructions, examples and code snippets are available.
              deepface saves you 1168 person hours of effort in developing the same functionality from scratch.
              It has 2932 lines of code, 74 functions and 37 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed deepface and discovered the below as its top functions. This is intended to give you an instant insight into deepface implemented functionality, and help decide if they suit your requirements.
            • Inception ResNet v2 .
            • Calculate face analysis .
            • Finds a VGG - based model using a given model .
            • Analyze model .
            • Verify two images .
            • Preprocess the input image .
            • Verify a VGG - compatible wrapper .
            • Detect the face of a given image .
            • representation function
            • Represent an image .
            Get all kandi verified functions for this library.

            deepface Key Features

            No Key Features are available at this moment for deepface.

            deepface Examples and Code Snippets

            RetinaFace,Installation
            Pythondot img1Lines of Code : 29dot img1License : Permissive (MIT)
            copy iconCopy
            pip install retina-face
            
            from retinaface import RetinaFace
            resp = RetinaFace.detect_faces("img1.jpg")
            
            {
                "face_1": {
                    "score": 0.9993440508842468,
                    "facial_area": [155, 81, 434, 443],
                    "landmarks": {
                      "right_eye": [2  
            Can DeepFace verify() accept an image array or PIL Image object?
            Pythondot img2Lines of Code : 2dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            results = DeepFace.verify(np.array(PILIMAGE), ...)
            
            Can DeepFace verify() accept an image array or PIL Image object?
            Pythondot img3Lines of Code : 8dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            picture= "extracted_face_picture/single_face_picture.jpg"
            picture= Image.open(picture)
            .
            .
            df.verify(picture, np.array(frame), "Facenet")
            
            df.verify(np.array(picture),np.array(frame), "Facenet")
            
            My OpenCV Live Webcam Demo Doesn't Show Accurate Emotions
            Pythondot img4Lines of Code : 4dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            Predictions = torch.argmax(Pred)
            
            Predictions = torch.argmax(Pred).item()
            
            Memory leakage issue in python list
            Pythondot img5Lines of Code : 30dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            for i in range(0, len(idendities) - 1):
                for j in range(i + 1, len(idendities)):
                    cross_product = itertools.product(samples_list[i], samples_list[j])
                    cross_product = list(cross_product)
            
                    for cross_sample in cross_
            Memory leakage issue in python list
            Pythondot img6Lines of Code : 14dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            for i in range(len(idendities) - 1):
                for j in range(i + 1, len(idendities)):
                    for cross_sample in itertools.product(samples_list[i], samples_list[j]):
                        # do something ...
            
            import csv
            for i in r
            ValueError: unknown format is not supported : ROC Curve
            Pythondot img7Lines of Code : 13dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            y_test = y_test.astype(int)
            
            from sklearn.metrics import confusion_matrix, accuracy_score, roc_auc_score, roc_curve
            
            y_pred_proba = predictions[::, 1]
            y_test = y_test.astype(int)
            
            
            fpr, tpr, _ = roc_curve(y_test, y_
            Python face detection not working in terminal
            Pythondot img8Lines of Code : 5dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            #!pip install deepface
            from deepface import DeepFace
            detectors = ['opencv', 'ssd', 'mtcnn', 'dlib']
            img = DeepFace.detectFace("img.jpg", detector_backend = detectors[0])
            
            DeepFace for extracting vector information of an image
            Pythondot img9Lines of Code : 267dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            !wget "http://*.jpg" -O "1.jpg"
            
            !wget "https://*.jpg" -O "2.jpg"
            
            import cv2
            from google.colab.patches import cv2_imshow
            im1 = cv2.imread("1.jpg")
            #cv2.imshow("img", im1)
            cv2_imshow(im1)
            
            How to calculate accuracy for facial recognition system?
            Pythondot img10Lines of Code : 20dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from sklearn.datasets import fetch_lfw_pairs
            fetch_lfw_pairs = fetch_lfw_pairs(subset = 'test', color = True, resize = 1)
            pairs = fetch_lfw_pairs.pairs
            labels = fetch_lfw_pairs.target
            
            predictions = []
            for i in rang

            Community Discussions

            QUESTION

            Bounding boxes returned without detected face image in dlib python
            Asked 2022-Jan-18 at 13:43

            I'm trying to detect multiple faces in a picture using the deepface library with dlib as the backend detector. I'm using the DlibWrapper.py from the deeepface library and i have the following issue: In some cases, the detector returns the bounding box coordinates but doesn't return the detected face image detected face-box coordinates.

            I was wondering if this bug occurs because of the negative values of some coordinates of the bounding boxes but i figured out that was not the case, as the negative values are features, not bugs. Here is the DlibWrapper from the deepface library.

            ...

            ANSWER

            Answered 2022-Jan-18 at 13:43

            Solved!There are edge cases where original rectangle is partially outside the image window. That happens with dlib. So, instead of

            • detected_face = img[top:bottom, left:right],

            the detected face should be

            • detected_face = img[max(0, top): min(bottom, img_height), max(0, left): min(right, img_width)]

            Source https://stackoverflow.com/questions/70754730

            QUESTION

            PermissionError: [Errno 13] Permission denied: .deepface
            Asked 2021-Oct-22 at 10:59

            I have installed a basic python server with deepface library with apache2 on ubuntu.

            The library makes a .deepface directory on app initialization but it is unable to do so due to permission denied error as it's hidden in linux by default. I am getting the following error

            ...

            ANSWER

            Answered 2021-Oct-22 at 10:59

            You can give permission to that hidden folder by typing sudo chmod 777 -R /var/www/.deepface. Make sure cheking the permission by cd /var/www/ and ls -lth

            Source https://stackoverflow.com/questions/69675561

            QUESTION

            OpenCv: change position of putText()
            Asked 2021-Jul-11 at 22:42

            I made a deep learning program that uses the webcam to recognize a persons emotion, race and gender. The text shows a persons characteristics is inside of each other. How can I move them underneath each other?

            The code

            ...

            ANSWER

            Answered 2021-Jul-11 at 22:42

            Change y - second value in (50,50), (40,50), (30,50) - ie. (50,50), (50,80), (50,110)

            Minimal working code

            Source https://stackoverflow.com/questions/68339674

            QUESTION

            Can DeepFace verify() accept an image array or PIL Image object?
            Asked 2021-Jun-08 at 12:03

            My DeepFace Implementation

            ...

            ANSWER

            Answered 2021-Jun-06 at 10:43

            If you are using this module, the documentation says:

            Herein, face pairs could be exact image paths, numpy array or base64 encoded images

            So, presumably, you can make your PIL Images into Numpy arrays like this:

            Source https://stackoverflow.com/questions/67856738

            QUESTION

            Tensor Tensor("flatten/Reshape:0", shape=(?, 2622), dtype=float32) is not an element of this graph
            Asked 2021-May-24 at 09:55

            Hello StackOverFlow Team: I built a model based on (Vgg_Face_Model) with weights loaded (vgg_face_weights.h5). Note that I use tensorflow-gpu = 2.1.0 , and keras=2.3.1 , with Anaconda 3 create it as interpreter and used with pycharm But the code shows an error in the part :

            ...

            ANSWER

            Answered 2021-May-24 at 09:55
            from tensorflow.python.keras.backend import set_session
            sess = tf.Session()
            
            #This is a global session and graph
            graph = tf.get_default_graph()
            set_session(sess)
            
            
            #now where you are calling the model
            global sess
            global graph
            with graph.as_default():
                set_session(sess)
                input_descriptor = [model.predict(face), img]
            

            Source https://stackoverflow.com/questions/67659336

            QUESTION

            Cannot set headers after they are sent to client
            Asked 2021-Mar-22 at 09:38

            I am creating an api that will call a python script using python-shell in nodejs.However when I am running the api,the api returns the error of "Cannot set headers after they have been sent to the client".Below is the code for the api.

            ...

            ANSWER

            Answered 2021-Mar-22 at 06:29

            If this if loop get executed a response will be send

            Source https://stackoverflow.com/questions/66740844

            QUESTION

            My OpenCV Live Webcam Demo Doesn't Show Accurate Emotions
            Asked 2021-Mar-19 at 12:34

            I developed a code by following a non-complete tutorial for emotion recognition with using PyTorch. I had so many errors but i fixed them thanks to the other questions here. But i simply stucked at this one. I am running my code, then my webcam opens but i see "Neutral" emotions all the time, even tough i perform different emotions. But on the console i am seeing other emotions as recorded, like:

            ...

            ANSWER

            Answered 2021-Mar-19 at 12:34

            Predictions is a tensor, so you need its value and not the tensor itself.

            Change this line:

            Source https://stackoverflow.com/questions/66708076

            QUESTION

            from numba import cuda, numpy_support and ImportError: cannot import name 'numpy_support' from 'numba'
            Asked 2021-Feb-04 at 13:35

            I am changing pandas into cudf to make faster aggregating and reduce the processing speed. I figure out one library which works on GPU with pandas.

            "CUDF LINK" https://github.com/rapidsai/cudf

            When I entered the below to install in my project it gives an error and I also tried many version of numba.

            ...

            ANSWER

            Answered 2021-Feb-04 at 13:35

            When trying to install cuDF 0.13, conda is apparently finding a numba version that is incompatible with that cuDF 0.13.

            cuDF 0.13 is out of date. The current stable release is 0.17 and the nightly is 0.18. We'll update the README, as it should provide installation instructions for the current version.

            We recommend creating a fresh conda environment. Please try the following conda install command, found here:

            Source https://stackoverflow.com/questions/66046111

            QUESTION

            Memory leakage issue in python list
            Asked 2021-Feb-02 at 05:59

            The identities list contains a big array of approximately 57000 images. Now, I am creating a negative list with the help of itertools.product(). This stores the whole list in memory which is very costly and my system hanged after 4 minutes.

            How can I optimize the below code and avoid saving in memory?`

            ...

            ANSWER

            Answered 2021-Feb-02 at 05:59

            The product from itertools is a generator so naturally it dose not store the whole list in memory, but in the next line, cross_product = list(cross_product) you convert it to list object which store the whole data in your memory.

            The idea of a generator is that you don't do all the calculation at the same time, as you do with your call list(itertools.product(samples_list[i], samples_list[j])). So what you want to do is generate the results one by one:

            Try something like this:

            Source https://stackoverflow.com/questions/65855793

            QUESTION

            ValueError: unknown format is not supported : ROC Curve
            Asked 2020-Dec-31 at 13:53

            I have just updated python version from 3.5 to 3.7 and getting an error in constructing ROC curve. I did not change anything in code but it gives some unknown error

            Code

            ...

            ANSWER

            Answered 2020-Dec-31 at 13:53

            if we print the value of type_of_target(y_test) the output value is "unknown". Now, we have to change the unknown to integer. So we will do like this

            Source https://stackoverflow.com/questions/65518308

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install deepface

            The easiest way to install deepface is to download it from PyPI. It's going to install the library itself and its prerequisites as well. Then you will be able to import the library and use its functionalities. Facial Recognition - Demo. A modern face recognition pipeline consists of 4 common stages: detect, align, represent and verify. Deepface handles all these common stages in the background. You can just call its verification, find or analysis function with a single line of code. Face Verification - Demo. This function verifies face pairs as same person or different persons. It expects exact image paths as inputs. Passing numpy or based64 encoded images is also welcome. Face recognition - Demo. Face recognition requires applying face verification many times. Herein, deepface has an out-of-the-box find function to handle this action. It's going to look for the identity of input image in the database path and it will return pandas data frame as output. Face recognition models - Demo. Deepface is a hybrid face recognition package. It currently wraps many state-of-the-art face recognition models: VGG-Face , Google FaceNet, OpenFace, Facebook DeepFace, DeepID, ArcFace and Dlib. The default configuration uses VGG-Face model. FaceNet, VGG-Face, ArcFace and Dlib overperforms than OpenFace, DeepFace and DeepID based on experiments. Supportively, FaceNet /w 512d got 99.65%; FaceNet /w 128d got 99.2%; ArcFace got 99.41%; Dlib got 99.38%; VGG-Face got 98.78%; DeepID got 97.05; OpenFace got 93.80% accuracy scores on LFW data set whereas human beings could have just 97.53%. Face recognition models are regular convolutional neural networks and they are responsible to represent faces as vectors. We expect that a face pair of same person should be more similar than a face pair of different persons. Similarity could be calculated by different metrics such as Cosine Similarity, Euclidean Distance and L2 form. The default configuration uses cosine similarity. Euclidean L2 form seems to be more stable than cosine and regular Euclidean distance based on experiments. Facial Attribute Analysis - Demo. Deepface also comes with a strong facial attribute analysis module including age, gender, facial expression (including angry, fear, neutral, sad, disgust, happy and surprise) and race (including asian, white, middle eastern, indian, latino and black) predictions. Age model got ± 4.65 MAE; gender model got 97.44% accuracy, 96.29% precision and 95.05% recall as mentioned in its tutorial. Streaming and Real Time Analysis - Demo. You can run deepface for real time videos as well. Stream function will access your webcam and apply both face recognition and facial attribute analysis. The function starts to analyze a frame if it can focus a face sequantially 5 frames. Then, it shows results 5 seconds.

            Support

            Pull requests are welcome. You should run the unit tests locally by running test/unit_tests.py. Please share the unit test result logs in the PR. Deepface is currently compatible with TF 1 and 2 versions. Change requests should satisfy those requirements both.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install deepface

          • CLONE
          • HTTPS

            https://github.com/serengil/deepface.git

          • CLI

            gh repo clone serengil/deepface

          • sshUrl

            git@github.com:serengil/deepface.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link