To build a gender and age detector that can approximately guess the gender and age of the person (face) in a picture or through webcam.
- In this particular practical I create project Gender and Age Prediction.
- For Age and Gender I used some pre-trained model which you can find in modelNweight folder.
- You can also try it on your image.
- Age is Categorized in Following Categories:
- (0-6)
- (7-13)
- (14-19)
- (20-29)
- (30-39)
- (40-55)
- (56-70)
- (71-100)
- It is very difficult to accurately guess an exact age from a single image because of factors like makeup, lighting, obstructions, and facial expressions. And so, I made this a classification problem instead of making it one of regression
For this python project, we used the Adience dataset; the dataset is available in the public domain and you can find it here. This dataset serves as a benchmark for face photos and is inclusive of various real-world imaging conditions like noise, lighting, pose, and appearance. The images have been collected from Flickr albums and distributed under the Creative Commons (CC) license. It has a total of 26,580 photos of 2,284 subjects in nine age ranges and is about 1GB in size. The models I used was trained on this dataset. By virtue of its large size, I only kept 3 folders of pictures.
To download the dataset on Kaggle, I showed you in downlod_data.py file.
pip install opencv-python
pip install matplotlib
pip install opendatasets
pip install pillow
pip install adafruit-io
-
For face detection, we have a .pb file- this is a protobuf file (protocol buffer); it holds the graph definition and the trained weights of the model. We can use this to run the trained model. And while a .pb file holds the protobuf in binary format, one with the .pbtxt extension holds it in text format. These are TensorFlow files. For age and gender, the .prototxt files describe the network configuration and the .caffemodel file defines the internal states of the parameters of the layers.
-
Download my Repository
-
Open your Command Prompt or Terminal and change directory to the folder in which all the files are located.
-
Detecting Gender and Age of face in Image Use Command :
py gad.py
Note: The Image should be present in same folder where all the files are present
- Python
- OpenCV
- Matplotlib
- Pillow
- Pandas
- OpenCV
- Matplotlib
- Pillow
- AdaBoost Classifier: https://blog.paperspace.com/adaboost-optimizer/
- Learning Rate Dropout: https://arxiv.org/abs/1912.00144
- Local Binary Patterns: https://medium.com/swlh/local-binary-pattern-algorithm-the-math-behind-it-%EF%B8%8F-edf7b0e1c8b3
- Stochastic Gradient Descent: https://towardsdatascience.com/stochastic-gradient-descent-clearly-explained-53d239905d31