Practical:11 PREDICTING GENDER AND AGE USING IMAGE DATA IN PYTHON

What is OpenCV?

OpenCV is short for Open Source Computer Vision. Intuitively by the name, it is an open-source Computer Vision and Machine Learning library. This library is capable of processing real-time image and video while also boasting analytical capabilities. It supports the Deep Learning frameworks TensorFlow, Caffe, and PyTorch.

What is a CNN?

A Convolutional Neural Network is a deep neural network (DNN) widely used for the purposes of image recognition and processing and NLP. Also known as a ConvNet, a CNN has input and output layers, and multiple hidden layers, many of which are convolutional. In a way, CNNs are regularized multilayer perceptrons.

Age and gender, two of the key facial attributes, play a very foundational role in social interactions, making age and gender estimation from a single face image an important task in intelligent applications, such as access control, human-computer interaction, law enforcement, marketing intelligence and visual surveillance, etc.

Here, we have performed Gender Detection i.e predicting ‘Male’ or ‘Female’ using deep learning libraries and OpenCV to mention the gender predicted.

Age detection is the process of automatically discerning the age of a person solely from a photo of their face.

There are a number of age detector algorithms, but the most popular ones are deep learning-based age detectors.

Getting Started

Extract the face Region of Interest (ROI), and apply the age detector algorithm to predict the age of the person

For Step-1, any face detector capable of producing bounding boxes for faces in an image can be used

The face detector produces the bounding box coordinates of the face in the image.

For Step-2, Detect faces from the input image, identifying the age of the person.

Given the bounding box (x, y)-coordinates of the face, we first extract the face ROI, ignoring the rest of the image/frame. Doing so allows the age detector to focus solely on the person’s face and not any other irrelevant “noise” in the image.

The face ROI is then passed through the model, yielding the actual age prediction.

Task: Identify and predict Gender and age-range from Photo.

Importing libraries.

Finding bounding box coordinates

Loading model and weight files

Mentioning age and gender category list

Function to predict gender and age

Uploading image

How image is processed

First, it reads the image using the cv2.imread() method.
After the image is resized to the appropriate size, we use our get_faces() function to get all the detected faces from the image. We iterate on each detected face image and call our get_age_predictions() and get_gender_predictions() to get the predictions. We print the age and gender.We draw a rectangle surrounding the face and also put the label that contains the age and gender text along with confidence on the image.

Finally, we show the image
Image1




Image2



Thank you:)

Comments

Popular posts from this blog

18IT100_Practical_Exam_Work

Practical:10 Getting started with Neo4j and Gephi Tool