Age Detection with FASTAI


I’ve been doing some research around age recognition and found some old forum threads and few other models that could do young/old classifications.

Looking further I found this paper - Gil Levi and Tal Hassner. Age and Gender Classification Using Convolutional Neural Networks. IEEE Workshop on Analysis and Modeling of Faces and Gestures (AMFG), at the IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), Boston, 2015.

This is the link to the paper and dataset -

Basically they provided images labeled using one out of 8 possible age categories: 0-2, 4-6, 8-12, 15-20, 25-32, 38-43, 48-53, 60-100. They also provided gender classification, which I did not use.

The paper, which dates back to 2015, said the model they build had 84.7% accuracy for age detection, so I made it my mission to beat that score using FASTAI!

I tried with many different learning rates, epochs, weight decay, etc. Eventually, I accomplish to get 84.4% accuracy with a Resnet 50. I was both happy and sad - it was close to 84.7% but I did not seem to be able to beat the 84.7%

That’s when I re-read the paper and found that I had completely misunderstood the accuracy of the model in the original paper: it was 50.7% (not 84.7%), meaning that the FASTAI model was 33.7% more accurate.

The 84.7% score I had seen was a metric they called “1-off” which meant the algorithm guessed the incorrect category, but it was adjacent to the right one. Hence I build a confusion matrix and calculated the “1-off” for the FASTAI model - it is 96.6%

All of the code is posted on my GitHub -
Hopefully, someone can find this information useful!

JP Jimenez


Yeah it is nice to see how far neutral nets have come. You will find a big difference between modern NN with fastai and older models.

This is one reason I’m a fan of fastai, it really allowed to to get amazing results in a packaged framework. If you were building this from scratch like other online classes, you would be struggling with the fundamentals without ever being able to catch up with everything that is happening in deep learning.


Agree. In my particular case, I learn a lot better by doing than anything else.
This has been what I appreciate the most about FASTAI - you can build a working model, and get interested enough so that you want to get better at it, and continue to learn the harder stuff.
The other way around is just not very motivating for me. Is like asking someone to learn to build chipsets and understand how telecom satellites work before using a cellphone!


Hi, paper author here (Gil Levi). Very nice work and CNNs have advanced a ton. However, the data is pre-divided into 5 folds. Did you follow that? otherwise you would probably get a data leak between train and test.

1 Like

Hi Gil,

This is quite possible - I will check the code. Also, I’ve been intending to learn the newer version of FASTAI, so this is a good opportunity to retake this and use the newer framework!

Thank you for your observation!