Click here to Skip to main content
15,119,410 members
Articles / Artificial Intelligence / Keras
Posted 17 Jul 2020


7 bookmarked

Age Estimation With Deep Learning: Getting Started

Rate me:
Please Sign up or sign in to vote.
5.00/5 (6 votes)
17 Jul 2020CPOL4 min read
In this article, we'll begin the process of how to use a deep neural network to estimate a person's age from an image.
Here, we'll look at choosing the appropriate method and tools (CNN), look at two different age estimation problems (regression and classification problem), some of the common steps for solving classification problems, and briefly discuss the merits of Keras, an open-source and cross-platform neural network library.

To properly serve customers, retailers must understand the demographics of their clientele. Acquiring such data is not always easy. What if retailers could automatically gather demographic information using their existing in-store security cameras?

In this series, you’ll learn how to use a Deep Neural Network (DNN) to estimate a person’s age from an image.


Let us state the problem of age estimation in terms of Deep Learning (DL). As the problem can be solved in many different ways, using various approaches of DL, we must first select the appropriate method and tools. We’ll use Convolutional Neural Networks (CNN) as the best modern tool for our task. CNN were introduced initially as a simple model of the human visual system. As they inherit some properties of the system, they can solve the same problems humans solve using their vision: classify objects, recognize faces, predict motion, and so on. The latest research shows that using CNN gives the most accurate age estimation from a face image.

Regression vs Classification

To use CNN, the age estimation problem can be stated in two different ways: as a regression problem or as a classification problem. For regression formulation, we have a set of face images with the known age of the person on every image. And then we train our network to estimate the age of a person from another image.

Image 1

In classification problems, we also have a set of images with age labels. But here, we divide the entire age interval into subintervals, introducing several age groups. So, we train the CNN to classify images in the sense of belonging to an age group (class).

Image 2

The classification formulation seems to be more suitable for our goal. First, we don't need to estimate a person’s age exactly, because it is enough for the retailers to know only the "age group" to predict the purchasing power of the customer. Second, the classification problem is easier to solve using the CNN approach, and there are many ready-to-use network architectures to cope with the various image classification problems. So this is what we’ll use – image classification.

Classification Step-by-Step

Here are the common steps for solving classification problems:

  1. Gathering image dataset. The image set used for learning and testing CNN is the first core ingredient for a successful solution. For our task, we need to get images with faces. All images should be of the same quality and size. The age of the person on every image must be known.
  2. Designing CNN structure. It is a common practice to develop a unique structure of CNN for solving any classification problem. This step is the most important to achieve the required accuracy. In our series, we are going to choose one of the popular CNN structures for image classification – the one that is most suitable for our problem.
  3. Creating CNN. Here, we need to implement the CNN we had designed using one of the existing DL frameworks. Fortunately, modern DL frameworks make building complex CNN easy.
  4. Training CNN for age estimation. In this step, we’ll use the created CNN and write some code to feed images to the network to train it for age classification. After the training, we’ll estimate the accuracy of the age prediction.
  5. Using CNN for age prediction. In this final step, we’ll use the pre-trained CNN to estimate a person’s age from an image. Here, we’ll need to write some code to load the CNN and the image, and run the age prediction.

In our series, each of the above steps features as a separate article.


The framework we’ll use for designing and creating CNN, as well as for implementing DL algorithms, is called Keras. There are several reasons we choose this framework. First, Keras is an open-source and cross-platform neural network library. Second, it supports all modern, state-of-the-art CNN architectures. And finally, it allows solving DL problems with minimal efforts and code writing. As Keras is aPython library, we’ll write all code in Python. You can install Keras in the Python development environment of your choice.

To work with images, we’ll need an image processing library. Our choice is OpenCV. This is a de-facto standard for image processing and computer vision. In addition, we’ll use some auxiliary libraries, such as Scikit-learn. These are typically pre-installed in common Python development environments.

Next Step

If – as we hope – you are going to follow along in this series, get Python-ready. Starting from the next article, we’ll guide you through the process of creating your own application for age estimation with DL.


  • 17th July, 2020: Initial version


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Sergey L. Gladkiy
Team Leader VIPAKS
Russian Federation Russian Federation

Master’s degree in Mechanics.

PhD degree in Mathematics and Physics.


15 years’ experience in developing scientific programs
(C#, C++, Delphi, Java, Fortran).


Mathematical modeling, symbolic computer algebra, numerical methods, 3D geometry modeling, artificial intelligence, differential equations, boundary value problems.

Comments and Discussions

-- There are no messages in this forum --