• Stars
    star
    482
  • Rank 91,212 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 5 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Python project which can detect gender and age using OpenCV of the person (face) in a picture or through webcam.

Gender-and-Age-Detection GitHub

Objective :

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.

About the Project :

In this Python Project, I had used Deep Learning to accurately identify the gender and age of a person from a single image of a face. I used the models trained by Tal Hassner and Gil Levi. The predicted gender may be one of โ€˜Maleโ€™ and โ€˜Femaleโ€™, and the predicted age may be one of the following ranges- (0 โ€“ 2), (4 โ€“ 6), (8 โ€“ 12), (15 โ€“ 20), (25 โ€“ 32), (38 โ€“ 43), (48 โ€“ 53), (60 โ€“ 100) (8 nodes in the final softmax layer). 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.

Dataset :

For this python project, I had 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 eight age ranges (as mentioned above) and is about 1GB in size. The models I used had been trained on this dataset.

Additional Python Libraries Required :

  • OpenCV
  •    pip install opencv-python
    
  • argparse
  •    pip install argparse
    

The contents of this Project :

  • opencv_face_detector.pbtxt
  • opencv_face_detector_uint8.pb
  • age_deploy.prototxt
  • age_net.caffemodel
  • gender_deploy.prototxt
  • gender_net.caffemodel
  • a few pictures to try the project on
  • detect.py

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.

Usage :

  • Download my Repository
  • Open your Command Prompt or Terminal and change directory to the folder where all the files are present.
  • Detecting Gender and Age of face in Image Use Command :
  •   python detect.py --image <image_name>
    

Note: The Image should be present in same folder where all the files are present

  • Detecting Gender and Age of face through webcam Use Command :
  •   python detect.py
    
  • Press Ctrl + C to stop the program execution.

Working:

Watch the video

Examples :

NOTE:- I downloaded the images from Google,if you have any query or problem i can remove them, i just used it for Educational purpose.

>python detect.py --image girl1.jpg
Gender: Female
Age: 25-32 years

>python detect.py --image girl2.jpg
Gender: Female
Age: 8-12 years

>python detect.py --image kid1.jpg
Gender: Male
Age: 4-6 years    

>python detect.py --image kid2.jpg
Gender: Female
Age: 4-6 years  

>python detect.py --image man1.jpg
Gender: Male
Age: 38-43 years

>python detect.py --image man2.jpg
Gender: Male
Age: 25-32 years

>python detect.py --image woman1.jpg
Gender: Female
Age: 38-43 years

More Repositories

1

Django-WebApp

This is a web-app created using Python, Django. By using this user can login, upload files and also can view and download files uploaded by other users.
Python
454
star
2

Games-Python-Turtle

This repository contains 5 games build using python turtle module.
Python
29
star
3

Web-Scraping-Python

It contains some web scraping examples implemented using Python.
Python
29
star
4

Space-Invader-Game

This is a space invader game created using python turtle module.
Python
23
star
5

File-Sorter

This is a python program for sorting files.
Python
21
star
6

Gym-Member-Management

A Gym Member Management System using Django
JavaScript
21
star
7

COVID-19-Detection-through-Chest-X-Ray

Detecting COVID-19 in X-ray images with Keras, TensorFlow, and Deep Learning
Python
10
star
8

Django-Blog

A simple Blog Application using Django
Python
6
star
9

Motion-Detector-Using-OpenCV

This python program will allow you to detect any motion that occurs in front of the builtin webcam and also store the time interval of the motions while creating a plot of the time interval using Bokeh Plot.
Python
6
star
10

Django-ToDo-App

This is a To-Do app build using django framework of python. Here user can create his todo list by adding items, crossed off the completed items, delete the completed items and can delete all the items.
Python
4
star
11

OpenCV-Face-and-Eye-Detection

Detects face and eyes of a person from image or webcam using opencv-python.
Python
3
star
12

CORONA-VIRUS-COUNTRY-STATUS

A python project for getting current status of corona cases in a particular country.
Python
3
star
13

Whatsapp-Post-Python

This is a python project to send a whatsapp message.
Python
3
star
14

Keylogger

This is a keylogger created using python.
Python
3
star
15

smahesh29

2
star
16

Django-Tutorials

Python
1
star
17

Flask-Todo-App

Todo App using Flask
HTML
1
star
18

Weather-App

This is a weather app in Django , it shows current weathers in multiple cities. You can add cities of your choice and can delete existing cities. I used Python Requests to call the Open Weather Map API.
Python
1
star
19

KnowYourLockdown

An Interactive dashboard which visualizes data on the Indian Map drilled down to each district. It shows the sentiments of people regarding lockdown (Positive, Negative, Neutral), mental health of population during lockdown & live patient count. The website will allow the government to know which region faces which problems(Food Shortage, Transportation, Economic, Daily services, Others ).
Python
1
star
20

Temperature-Converter

It is a Temperature Converter using java swing. It includes the following units : Celsius, Fahrenheit, Kelvin, Rankine, Reaumur.
Java
1
star