How the age detection works
We use state-of-the-art computer vision and Deep Learning algorithms to estimate the age of the person in the picture.
The facial age detector consists of 2 components: A face extractor that locates the face of the image and normalizes it, and a neural network that uses the extracted face to predict the age.
The open-source tool OpenCV is used to locate and extract the face. If multiple faces are detected, one is randomly picked (We might improve this in the future). Black bars are added to the sides to make the result a squared image of the size 224 x 224 pixels.
The actual facial age detection is performed by a customized Deep Neural Network based on the ResNet architecture, which was shown to produce good results on various image analysis tasks. The Original ResNet is a classification model, meaning that it predicts in which category (car, dog, house, etc.) the image fits and has an output for each possible category. Since age prediction is not a categorical task, we removed the last layer of the ResNet and replaced it with a single output that represents the age. (output is a number between 0 and 1, that is then scaled to 0 - 100).
We trained the Neural Network with a dataset consisting of thousands of facial images with age labels and verified that the model is working with a testing dataset that has not been used during the training phase.
Website and Full Architecture
All tools we use to operate the model and the website to interact with it are part of the Google Cloud Platform. We created a Docker Image that uses the previously mentioned face extractor and age detection model and provides an API using Django REST. Based on this Docker Image, we create a VM with Google Compute Engine. For the website, we use Google App Engine, which is a managed environment that can be used to easily host simple web applications built with Flask. The Flask app connects to the API described above to calculate the age.
Can I use your API?
Have a look at Use our Age Detection API.
For what can this tool be used?
This website is mainly a demo to show what is possible nowadays with AI, but there are also real-world use cases where automated age detection makes sense. For example, Instagram is experimenting with using a similar approach to verify if users are old enough to use the platform. Uploading a selfie is more privacy-friendly compared to requiring users to upload a picture of their ID or passport.
Check out our age estimation testFind out how old you look