explaingit

oarriaga/face_classification

5,730PythonAudience · developerComplexity · 3/5Setup · moderate

TLDR

A Python project that detects faces in images or live webcam video and classifies each face by emotion and gender in real time, using pre-trained Keras models with about 66% emotion accuracy and 96% gender accuracy.

Mindmap

mindmap
  root((repo))
    What it does
      Detect faces
      Classify emotion
      Classify gender
      Real-time webcam
    Models
      7 emotion classes
      Binary gender classes
      Pre-trained weights
    Run modes
      Live webcam demo
      Single image script
      Docker web service
    Training
      fer2013 dataset
      IMDB face dataset
      Custom retraining
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Run real-time emotion detection on a webcam feed with a single Python command

USE CASE 2

Process a batch of portrait images to label each face with an emotion and gender prediction

USE CASE 3

Deploy the classifier as a local web service using Docker and send images to it via HTTP

USE CASE 4

Retrain the emotion model on a custom dataset using the provided training scripts and fer2013-format data

Tech stack

PythonKerasOpenCVTensorFlowDocker

Getting it running

Difficulty · moderate Time to first run · 1h+

Requires specific older versions of Keras and TensorFlow, the author has deprecated this repo in favor of the paz rewrite.

No license information is specified in the repository.

In plain English

This repository contains code for detecting faces in images and video and then classifying the detected faces by emotion and gender in real time. It was built using Keras (a Python library for building neural networks), OpenCV (a library for computer vision tasks like reading camera input), and two publicly available datasets: fer2013 for emotions and IMDB for gender. The emotion model was trained to recognize seven emotional states and achieves about 66% accuracy on its test set. The gender model reaches 96% accuracy. The repository includes demo scripts for running classifications live from a webcam, processing a single image, or visualizing which parts of the face the model pays attention to when making its predictions (a technique called guided backpropagation). You can also run the classifier as a web service using a pre-built Docker image. That setup starts a small server on your machine and accepts image uploads, returning the annotated image with predictions drawn on it. For those who want to train their own versions of these models, the README provides instructions for downloading the required datasets and running the training scripts. The fer2013 dataset is available from a Kaggle competition page, and the IMDB face dataset is hosted by a university research group. Training requires downloading several gigabytes of data. The README notes that this repository is deprecated. The author has moved the project to a newer codebase called paz, which was rewritten to be compatible with TensorFlow 2.0. The original code here still works for the older framework versions it was written for.

Copy-paste prompts

Prompt 1
Using the face_classification webcam demo, help me modify it to log each emotion prediction with a timestamp to a CSV file so I can analyze mood patterns over time.
Prompt 2
I want to run the Docker web service from oarriaga/face_classification and send it a folder of images via curl, saving the annotated output images. Write me the shell script to do that.
Prompt 3
Show me how the guided backpropagation visualization script works in this repo and help me generate attention maps for a set of my own portrait photos to see what the model focuses on.
Prompt 4
Help me retrain the gender model from face_classification on a custom dataset I have in fer2013 CSV format, using the existing training scripts with my own data paths and class labels.
Open on GitHub → Explain another repo

← oarriaga on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.