In this blog, we are going to discuss a fun project that’s built on a face detection model. Age detection can be used in the industry to customize ads in stores to see what groups of people are most likely to buy the product. It can also be used in forensic sciences, where often only the description of a suspect is available, usually the data that is always available are the gender and an age range, which would be very useful in reducing the list of candidates to be compared with the sketch to get the answers to be more precise. We will be looking at the architecture of the model briefly, along with its deployment on the Flo Edge One and its inferences.
Before we get into that, let’s take a quick look at the Flo Edge One, a must-have in every AI and robotics engineer’s toolbox. Here are some remarkable benchmarks that make it a top competitor in edge devices!
- Pre-installed with Ubuntu 22.04 and tools like ROS2, OpenCV, TFlite, etc.
- Qualcomm Adreno 630 GPU.
- 12 MP 4k camera at up to 30fps
- Inferencing the face detection model as well as the age detection model at 57 milliseconds producing a smooth output of around 12 fps.
Introduction:
The age detection model basically consists of an OpenCV face detection model and a classifier model for the detected faces.
The base model used, aka, the face detection model is an OpenCV model but you can always use mediapipe’s face detection model as well. The difference comes through in performance factors like FPS and inference time. These differences will be discussed later under performance analysis.
Dataset and Model:
For the purpose of Face detection, OpenCV is used to implement the Haar Cascade classifier. Haar cascade classifier is a widely used face detection model as the base for models like gender detection, age detection, mask detection, facial recognition, etc. Haar cascade is a feature based binary classifier which essentially uses a function represented by a window that runs of the entire image. It tries to classify every region in an image as positive or negative which means the region is either part of our object or it is not. In this case our object is a face. By doing this, we obtain the group of pixels that contain all the features that represent a face. Note that this can only be used for face detection and not recognition since it is trained on multiple different faces and the general features that are common to most faces. Given below are some examples of cascading function windows.
Once we obtain our region of interest in the image, i.e., the face, A basic classification model with 9 class labels is used for age detection. These 9 classes are – 4 to 6, 7 to 8, 9 to 11, 12 to 19, 20 to 27, 28 to 35, 36 to 45, 46 to 60, and, 61 to 75.
The labels must’ve been obtained based on inter class distinction and intra class distinction. This means that the range in the first class is much smaller than the eighth class but that must be because the facial feature difference between ages 6 and 7 must be far more distinct than the difference between ages 46 and 47. These 9 groups could’ve been obtained using some clustering method on images of all age groups.
Usage:
Another alternative to running this model efficiently is using the Flo Edge One GPU! What is Flo Edge One you ask? This impressive device boasts a light GPU that can deliver smooth results, all while maintaining a high level of accuracy. The Flo Edge One is truly a remarkable device, providing a plethora of impressive features that make it a must-have for tech enthusiasts. With its onboard camera, inbuilt IMU, and GNSS capabilities, this device truly has it all. It comes pre-installed with Ubuntu 22.04, ROS2, OpenCV, and various other tools, making it the perfect choice for your robotics ventures. The best part? Amidst the semiconductor crisis, the Flo Edge One is affordable and ready to ship! So you can get started ASAP, without breaking the bank.
Starting a new venture and wanna figure out what your target audience might be? Using the 12MP camera on your Flo Edge One, run the age detection model real-time to and understand what age groups your products appeal to.
Performance Analysis:
The inference time of the model was around 58 milliseconds on the Flo Edge GPU. This is because the face detection model is quite simple and light and easy on computation. The output of this model is fed as the input to the age classifier which classifies most people pretty accurately based on their facial features. The model gives an FPS of about 11 which is a little slow but that is because there are 9 classes and it is capable of simultaneously classifying multiple faces in a single frame.
The only downside to this model is the use of Haar Cascades for face detection. While it is very light weight and straight forward, making it perfect for real-time applications, it detects many false positives as seen in the video above. It is also not as accurate as an object detection model like YOLO. As mentioned before, this can be replaced with any other pre-trained face detection model like YOLO or mediapipe face detection, if more accuracy is desired.
This being said, it is the most efficient model to use as a base for a different model because it is light weight and any GPU/CPU should be able to run both models with ease, even on SBCs like the Flo Edge.
Conclusion:
The Age detection model yields incredibly accurate predictions when run on the Flo Edge GPU even after being compressed as a .tflite model architecture. Coupled with the 12 MP onboard camera a wide range of systems can be developed for use cases like surveillance, security, marketing and sales, and forensics.