How it works...

In this recipe, we used two different models: one for gender classification and one for age group classification. Note that in this recipe, in contrast with the others, we subtract per-pixel mean values from the source image, not per-channel values. You can actually visualize the mean values and see the average human face.

Here's the input image:

The following output is expected:

Gender: female with prob: 0.9362890720367432Age group: (25, 32) with prob: 0.9811384081840515

Get OpenCV 3 Computer Vision with Python Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.