Machine Learning based Age and Gender Predictions in Image Processing

Erandi Ganepola
4 min readFeb 23, 2017

--

Age and gender play a major role in someone’s identification. Automatic age and gender classification has become relevant to an increasing amount of applications, particularly since the rise of social platforms and social media. Hiding true values of these variables can cause for security issues mainly. When it comes to Image Processing, an image or a video frame is taken as the input and by processing, expected predictions will be out putted. As the processing mechanism various algorithms and techniques have been used since years. From this article, introduction about Machine Learning (ML) based relevant algorithms, techniques on age and gender predictions and how those are related with Image Processing will be discussed.

For age and gender predictions, researchers have come up with various algorithms using classification and ML concepts. Most primitive type algorithms are used to derive many secondary algorithms with improvements. “Fisherfaces” and “Eigenfaces” algorithms are considered as primitive ones. Also Deep Convolutional Neural Networks (CNN) is another technique that can be used. Those algorithms are described briefly in next paragraphs.

The Principal Component Analysis (PCA), which is the core of the Eigenfaces method, finds a linear combination of features that maximizes the total variance in data. While this is clearly a powerful way to represent data, it doesn’t consider any classes and so a lot of discriminative information may be lost when throwing components away. Imagine a situation where the variance in your data is generated by an external source, let it be the light. The components identified by a PCA do not necessarily contain any discriminative information at all, so the projected samples are smeared together and a classification becomes impossible. Eigenfaces algorithmic description can be found here: [link]

The Linear Discriminant Analysis performs a class-specific dimensionality reduction and was invented by the great statistician Sir R. A. Fisher. He successfully used it for classifying flowers in his 1936 paper. The use of multiple measurements in taxonomic problems. In order to find the combination of features that separates best between classes the Linear Discriminant Analysis maximizes the ratio of between-classes to within-classes scatter, instead of maximizing the overall scatter. The idea is that same classes should cluster tightly together, while different classes are as far away as possible from each other in the lower-dimensional representation. Fisherfaces algorithmic description can be found here [link]

If you want to decide whether a person is male or female, you have to learn the discriminative features of both classes. The Eigenfaces method is based on the Principal Component Analysis, which is an unsupervised statistical model and not much suitable for gender prediction task. The Fisherfaces method achieves a 98% recognition rate in a subject-independent cross-validation. (A subject-independent cross-validation means images of the person under test are never used for learning the model).

In modern deep CNN, their network is relatively modest due to the better computational resources of the time and the algorithmic possibilities of training bigger networks. Though much potential laid in deeper CNN architectures (networks with more neuron layers), only recently have they became prevalent, following the dramatic increase in both the computational power (due to Graphical Processing Units), the amount of training data readily available on the Internet, and the development of more effective methods for training such complex models. One recent and notable examples is the use of deep CNN for image classification on the challenging Image net benchmark. Deep CNN have additionally been successfully applied to applications.

A CNN for age and gender estimation gathering a large, labeled image training set for age and gender estimation from social image repositories requires either access to personal information on the subjects appearing in the images (their birth date and gender), which is often private, or is tedious and time-consuming to manually label. Data-sets for age and gender estimation from real-world social images are therefore relatively limited in size and presently no match in size with the much larger image classification data-sets. Over fitting is common problem when machine learning based methods are used on such small image collections. This problem is exacerbated when considering deep convolutional neural networks due to their huge numbers of model parameters.

Both Fisherfaces algorithm and deep CNN are commonly used for age and gender predictions. When it comes to CNN already trained sets are available with their results such as age_net and gender_net. Those net files can be used when processing.

In image processing, what basically happens is, an image or video frame will be taken as the input and it will be processed to output results. Images / video frames consist with pixels and those will be converted in to matrices. Then those matrices are used for processing. Many libraries and programming languages are available to support those tasks. OpenCV is one of the most popular libraries and languages like Phython, C, C++, Java, Mathlab, Octave are commonly used for these tasks.

References

[1]http://www.openu.ac.il/home/hassner/projects/cnn_agegender/

[2]http://docs.opencv.org/2.4/modules/contrib/doc/facerec/facerec_tutorial.html

--

--

Erandi Ganepola

Solutions Architecture | Thinker | @WSO2 LLC for North America