mtcnn | MTCNN face detection implementation for TensorFlow | Computer Vision library

 by   ipazc Jupyter Notebook Version: 0.1.1 License: MIT

kandi X-RAY | mtcnn Summary

kandi X-RAY | mtcnn Summary

mtcnn is a Jupyter Notebook library typically used in Artificial Intelligence, Computer Vision, Deep Learning, Tensorflow applications. mtcnn has no vulnerabilities, it has a Permissive License and it has medium support. However mtcnn has 1 bugs. You can download it from GitHub.

MTCNN face detection implementation for TensorFlow, as a PIP package.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              mtcnn has a medium active ecosystem.
              It has 1991 star(s) with 495 fork(s). There are 41 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 64 open issues and 38 have been closed. On average issues are closed in 95 days. There are 5 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of mtcnn is 0.1.1

            kandi-Quality Quality

              mtcnn has 1 bugs (0 blocker, 0 critical, 1 major, 0 minor) and 7 code smells.

            kandi-Security Security

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

            kandi-License License

              mtcnn 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

              mtcnn releases are not available. You will need to build from source code and install.
              mtcnn saves you 248 person hours of effort in developing the same functionality from scratch.
              It has 604 lines of code, 46 functions and 12 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed mtcnn and discovered the below as its top functions. This is intended to give you an instant insight into mtcnn implemented functionality, and help decide if they suit your requirements.
            • Create a convolution layer
            • Creates a new variable with given shape and shape
            • Add a layer output
            • Validate the grouping
            • Returns whether the model is trainable
            • Get a layer by name
            • Build the P and OT matrix from a file
            • Assign weights to the network
            • Builds the network
            • Build rnet
            • Build an ONN layer
            • Create a new fully connected layer
            • Vectorize input layer
            • Detect the faces of the image
            • Compute a scale pyramid
            • Create a pre - convolution layer
            • Creates a softmax layer
            • Create a new max pool
            • Feed an image
            • Add a new feed layer
            Get all kandi verified functions for this library.

            mtcnn Key Features

            No Key Features are available at this moment for mtcnn.

            mtcnn Examples and Code Snippets

            Sorting a tensor list in ascending order
            Pythondot img1Lines of Code : 8dot img1License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            namestodistance = [('Alice', .1), ('Bob', .3), ('Carrie', .2)]
            names_top = sorted(namestodistance, key=lambda x: x[1])
            print(names_top[:2])
            
            namestodistance = list(map(lambda x: (x[0], x[1].item()), namestodistance)
            Mtcnn face-extractor for head extraction
            Pythondot img2Lines of Code : 16dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import mtcnn
            
            img = cv2.imread('images/'+path_res)
            
            faces = []
            for result in detector.detect_faces(img):
                x, y, w, h = result['box']
            
                b = max(0, y - (h//2))
                d = min(img.shape[0], (y+h) + (h//2))
                a = max(0, x - (w//2):(x+w))
            
            TypeError: tuple indices must be integers or slices, not str, when using MTCNN
            Pythondot img3Lines of Code : 13dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            for person in face_locations:
            bounding_box = person['box']   
            keypoints = person['keypoints']
            
            person = face_locations[0]
            bounding_box = person['box']
            keypoints = person['keypoints']
            print(bounding_box, keypoints)
            <
            Activate Virtual environment using c#
            Pythondot img4Lines of Code : 31dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            class ProjectTitle
            
            public partial class ProjectTitle : Form
            
             static void Main(string[] args)
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDe
            Python OpenCV LoadDatasetList, what goes into last two parameters?
            Pythondot img5Lines of Code : 24dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            images_train = []
            landmarks_train = []
            status = cv2.face.loadDatasetList(args.training_images, args.training_annotations, images_train, landmarks_train)
            
            def my_loadDatasetList(text_file_images, text_file_annotation
            How to store images with bounding box in a folder using python google colab?
            Pythondot img6Lines of Code : 8dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            pixels = cv2.imread(filename)
            
            pixels = pyplot.imread(filename)
            
            matplotlib.pyplot.savefig(img, bbox_inches='tight', pad_inches=0)
            
            pyplot.savefig('/content/drive/My D
            copy iconCopy
            REQUIRED_PACKAGES = ['torchvision==0.5.0', 'torch @ https://download.pytorch.org/whl/cpu/torch-1.4.0%2Bcpu-cp37-cp37m-linux_x86_64.whl', 'opencv-python', 'facenet-pytorch']
            
            ValueError: sampler option is mutually exclusive with shuffle pytorch
            Pythondot img8Lines of Code : 26dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            train_indices = [0, 2, 3, 4, 5, 6, 9, 10, 12, 13, 15]
            val_indices = [1, 7, 8, 11, 14]
            
            val_indices = [1, 8, 11, 7, 14]  # Epoch 1
            val_indices = [11, 7, 8, 14, 1]  # Epoch 2
            val_indices = [7, 1, 14, 8, 11]  # Epoch 3
            Numpy append sometimes works, sometimes doesn't
            Pythondot img9Lines of Code : 10dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            Dataset.append(np.expand_dims(array, axis=0))
            
            embeddings = Dataset
            
            embeddings.append(embeds)
            
            np.append(embeddings, embeds)
            
            embeddings = list(Dataset)
            
            Python TensorRT: CUDNN_STATUS_MAPPING_ERROR Error
            Pythondot img10Lines of Code : 10dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            tf.Session(config=tf.ConfigProto(gpu_options=tf.GPUOptions(allow_growth=True))).__enter__()
            
            h_input = cuda.pagelocked_empty(trt.volume(engine.get_binding_shape(0)), dtype=np.float32)
            h_output = cuda.pagelocked_empt

            Community Discussions

            QUESTION

            No module named [mtcnn] - m1 Mac - python
            Asked 2022-Jan-08 at 02:19

            I am trying to import the module mtcnn in VSCode. I have run the following commands in the terminal:

            ...

            ANSWER

            Answered 2022-Jan-07 at 06:11
            1. Open an integrated terminal in VS Code, run python --version to check if it's as the same as the one you selected for python interpreter, which is shown in status bar.
            2. Run pip show mtcnn. If you get detailed information like name, version and location, reload window should solve your question. If you get WARNING: Package(s) not found: mtcnn, it means no such module in your current selected environment, install it.

            Besides, to avoid messing up the global python environment, you may create a virtual environment. See Create a Virtual Environment.

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

            QUESTION

            Sorting a tensor list in ascending order
            Asked 2021-Dec-05 at 21:29

            I am working on a facial comparison app that will give me the closest n number of faces to my target face.

            I have done this with dlib/face_recognition as it uses numpy arrays, however i am now trying to do the same thing with facenet/pytorch and running into an issue because it uses tensors.

            I have created a database of embeddings and I am giving the function one picture to compare to them. What i would like is for it to sort the list from lowest distances to highest, and give me the lowest 5 results or so.

            here is the code I am working on that is doing the comparison. at this point i am feeding it a photo and asking it to compare against the embedding database.

            ...

            ANSWER

            Answered 2021-Dec-05 at 16:43

            Unfortunately I cannot test your code, but to me it seems like you are operation on a python list of tuples. You can sort that by using a key:

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

            QUESTION

            Mtcnn face-extractor for head extraction
            Asked 2021-Dec-05 at 20:21

            I'm using Mtcnn network (https://towardsdatascience.com/face-detection-using-mtcnn-a-guide-for-face-extraction-with-a-focus-on-speed-c6d59f82d49) to detect faces and heads. For this I'm using the classical lines code for face detection :I get the coordinate of the top-left corner of the bouding-box of the face (x,y) + the height and width of the box (h,w), then I expand the box to get the head in my crop :

            ...

            ANSWER

            Answered 2021-Dec-05 at 20:21

            You can use relative instead of absolute sizes for the margins around the detected faces. For example, 50% on top, bottom, left and right:

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

            QUESTION

            PyTorch resnet bad tensor dimensions
            Asked 2021-Sep-03 at 14:02

            I'm trying to setup a face detection/recognition pipeline using Pytorch.

            I load the image using opencv

            ...

            ANSWER

            Answered 2021-Sep-03 at 14:02

            I tried removing the unsqueeze and it worked
            The guide I was following was using something other than opencv to load the image which probably returned the image as an array/tensor of images

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

            QUESTION

            count Yaw and Roll in Python Head pose estimation MTCNN
            Asked 2021-May-01 at 09:04

            I have encountered implementation of MTCNN network which is able to detect our head movement in 3 axis called Yaw,Roll and Pitch.

            Here are crucial elements:

            ...

            ANSWER

            Answered 2021-May-01 at 09:04

            Yaw, Roll and Pitch are Euler angles - the image below shows a more easy to understand example, it is important to note that the rotations are not in relation to the global axis but are in fact in relation to objects axis that's why a plane is a good thing to think about. Also there are several different formats of Euler angles to understand better look at the wiki

            looking at the github link you provided I have found the following:

            1. the points contain the coordinates of different facial features within the frame, where:

              X=points[0:5] Y=points[5:10]

            2. they do not measure these angles in degrees:

            Roll: -x to x (0 is frontal, positive is clock-wise, negative is anti-clock-wise)

            Yaw: -x to x (0 is frontal, positive is looking right, negative is looking left)

            Pitch: 0 to 4 (0 is looking upward, 1 is looking straight, >1 is looking downward)

            1. the function for Yaw, Roll and Pitch do not return the angle:

            what is returned from Roll is the Y coordinate of the left eye minus the y coordinate of the right eye

            Yaw is essentially calculating which eye the noise is closer to along the x axis - as you turn your head the nose appears closer to one eye from an observer

            1. find_pose might have what you are looking for but I need to do further research into what is meant by xfrontal and yfrontal - you may need to pose the question directly to the person on github

            Update: after posing the question directly to the developer, they have responded with the following:

            Roll, Yaw and Pitch are in pixels and provide an estimate of where the face looking at. In case of mtcnn Roll is (-50 to 50), Yaw is (-100 to 100). Pitch is 0 to 4 because you can divide the distance between eyes and lips into 4 units where one unit is between lips to nose-tip and 3 units between nose-tip to eyes.

            Xfrontal and Yfrontal provide pose (Yaw and Pitch only) in terms of angles (in degrees) along X and Y axis, respectively. These values are obtained after compensating the roll (aligning both the eyes horizontally).

            https://github.com/fisakhan/Face_Pose/issues/2

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

            QUESTION

            How to save the image with the red bounding boxes on it detected by mtcnn?
            Asked 2021-Apr-28 at 01:21

            I have this code in which mtcnn detects faces on an image, draws a red rectangle around each face and prints on the screen.

            Code taken from: https://machinelearningmastery.com/how-to-perform-face-detection-with-classical-and-deep-learning-methods-in-python-with-keras/

            But I want to save the image with the red boxes arround each face. So that i can do some preprocessing on it. Any help is good.

            ...

            ANSWER

            Answered 2021-Apr-28 at 01:21

            You can use matplotlib.pyplot.savefig. For example:

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

            QUESTION

            Activate Virtual environment using c#
            Asked 2020-Dec-08 at 20:55

            Is it possible to activate virtual environment created without using the anaconda prompt? For instance, I want to activate my virtual environment in c# in order to execute my python code.

            This is my current code

            ...

            ANSWER

            Answered 2020-Dec-08 at 20:55

            I found a way to do this but I still have to open a command prompt.

            First, I created a console project in visual studio. Then, I turned the console into Windows application by going to the project's properties and change the output type to Windows Application. After that change your code from

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

            QUESTION

            Setting a protobuf item's value replaces a previously set variable as well
            Asked 2020-Dec-05 at 06:13

            I have created a simple Protobuf based config file and have been using it without any issues until now. The issue is that I added two new items to my settings (Config.proto) and now whatever value I set for the last variable is reflected in the previous one.

            The following snapshot demonstrates this better. As you can see below, the value of fv_shape_predictor_path and fv_eyenet_path depend solely on order of being set. the one that is set last changes the others value.

            I made sure the cpp files related to Config.proto are built afresh. I also tested this under Linux and there it works just fine. It seems its only happening in windows! it also doesn't affect any other items in the same settings. its just these two new ones.

            I have no idea what is causing this or how to go about it. For reference this is how the protobuf looks like:

            ...

            ANSWER

            Answered 2020-Dec-05 at 06:13

            This issue seems to only exist in the Windows version of Protobuf 3.11.4 (didn't test with any newer version though).

            Basically what happened was that I use to first create a Config object and initialize it with some default values. When I added these two entries to my Config.proto, I forgot to also add an initialization entry like other entries, thinking I'm fine with the default (which I assumed would be "").

            This doesn't pose any issues under Linux/G++ and the program builds and runs just fine and works as intended. However under Windows this results in the behavior you just witnessed i.e. setting any of those newly added entries, would also set the other entries values. So basically I either had to create a whole new Config object or had to explicitly set their values when using the load_default_config.

            To be more concrete this is the snippet I used for setting some default values in my Protobuf configs.

            These reside in a separate header called Utility.h:

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

            QUESTION

            Python OpenCV LoadDatasetList, what goes into last two parameters?
            Asked 2020-Oct-04 at 14:33

            I am currently trying to train a dataset using OpenCV 4.2.2, I scoured the web but there are only examples for 2 params. OpenCV 4.2.2 loadDatasetList requires 4 parameters but there have been shortcomings which I did my best to overcome with the following. I tried with an array at first but loadDatasetList complained that the array was not iterable, I then proceeded to the code below with no luck. Any help is appreciated thank you for your time, and hope everyone is being safe and well.

            The prior error passing in an array without iter()

            PS E:\MTCNN> python kazemi-train.py No valid input file was given, please check the given filename. Traceback (most recent call last): File "kazemi-train.py", line 35, in status, images_train, landmarks_train = cv2.face.loadDatasetList(args.training_images,args.training_annotations, imageFiles, annotationFiles) TypeError: cannot unpack non-iterable bool object

            The current error is:

            PS E:\MTCNN> python kazemi-train.py Traceback (most recent call last): File "kazemi-train.py", line 35, in status, images_train, landmarks_train = cv2.face.loadDatasetList(args.training_images,args.training_annotations, iter(imageFiles), iter(annotationFiles)) SystemError: returned NULL without setting an error

            ...

            ANSWER

            Answered 2020-Oct-04 at 07:37

            The figure you provided refers to the C++ API of loadDatasetList(), whose parameters usually cannot be mapped to that of Python API in many cases. One reason is that a Python function can return multiple values while C++ cannot. In the C++ API, the 3rd and 4th parameters are provided to store the output of the function. They store the paths of the images after reading from the text file at imageList, and the paths of the annotations by reading another text file at annotationList respectively.

            Going back to your question, I cannot find any reference for that function in Python. And I believe the API is changed in OpenCV 4. After multiple trials, I am sure cv2.face.loadDatasetList returns only one Boolean value, rather than a tuple. That's why you encountered the first error TypeError: cannot unpack non-iterable bool object even though you filled in four parameters.

            There is no doubt that cv2.face.loadDatasetList should produce two lists of file paths. Therefore, the code for the first part should look something like this:

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

            QUESTION

            How to store images with bounding box in a folder using python google colab?
            Asked 2020-Sep-12 at 06:55

            I am trying to save the images after detecting faces in them. I tried using matplotlib.pyplot.savefig(img, bbox_inches='tight', pad_inches=0) and this stored images but all the images stored are blank white images. The output I get

            what I want it to store is:- The Output I expect

            ...

            ANSWER

            Answered 2020-Sep-12 at 06:55

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

            Vulnerabilities

            No vulnerabilities reported

            Install mtcnn

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            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 mtcnn

          • CLONE
          • HTTPS

            https://github.com/ipazc/mtcnn.git

          • CLI

            gh repo clone ipazc/mtcnn

          • sshUrl

            git@github.com:ipazc/mtcnn.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