Skip to content
Projects

murtiunlimited/face-emotion-recognition

View on GitHub

About

Real-time Face & emotion recognition system using a lightweight CNN, with OpenCV webcam inference, GroqCloud for chatbot & FastAPI + frontend web deployment.

Web & App Development

How these counts are measured

What you can do

  • Real-time emotion detection
  • Lightweight CNN (fast inference)
  • Works with webcam + browser
  • FastAPI backend for scalable deployment

Measured star growth

in 24h
0
in 7 days
0
in 15 days
Collecting history
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

Facial Emotion Recognition (FER Project)

This project performs real-time facial emotion detection using a CNN model.
It supports both:

  • OpenCV (desktop webcam)
  • Web browser (FastAPI + frontend)
  • Web Browser Version With Shell
  • Vercel and Render For Web Deployment (TBD)

📁 Project Setup and Structure

FER-PROJ-2/
├── .github/
│   ├── workflows/
│   ├── ci.yml
├── api/
│   ├── app.py
│   ├── __init__.py
├── data/
│   ├── processed/
│   │   ├── train/
│   │   └── validation/
│   └── raw/
│       ├── test/
│       └── train/
├── frontend/
│   └── index.html
│   ├── ai.html
│   ├── realtime.html
├── tests/
│   ├── test_api.py
│   ├── test_data.py
│   ├── test_imports.py
│   ├── test_inference.py
│   ├── test_model.py
├── models/
│   ├── best_emotion_model.keras
│   └── final_emotion_model.keras
└── src/
    ├── data/
    │   ├── __pycache__/
    │   ├── __init__.py
    │   ├── preprocess.py
    ├── inference/
    │   ├── __init__.py
    │   ├── predict.py
    │   └── webcam.py # if user prefers openCV
    ├── llm/
    │   ├── __init__.py
    │   ├── groq_client.py
    ├── models/
    │   ├── __init__.py
    │   ├── evaluate.py  # MLFLOW included
    │   ├── model.py
    │   └── train.py     # MLFLOW included
    ├── utils/
    │   ├── __init__.py
    │   └── config.py
    └── __init__.py
├── Dockerfile
├── README.md
├── render.yaml
├── .env (MAKE SURE TO ADD IN GITIGNORE FILE)
├── .gitattributes
├── requirements.txt
├── run_pipeline.py # if user prefers web version by python script
└── shellscript.sh  # if user prefers web version by shell script

1. Create Virtual Environment

python -m venv venv

2. Activate Virtual Environment

Windows:

venv\Scripts\activate

Mac/Linux:

source venv/bin/activate

3. Install Requirements

pip install -r requirements.txt
pip install -r requirements-dev.txt

OpenCV Version (Desktop Webcam)

1. Preprocess Data

python -m src.data.preprocess

2. Train Model

python -m src.models.train

3. Run Webcam Detection

python -m src.inference.webcam

Web Browser Version (FastAPI + Frontend)

Step 1: Preprocess Data

python -m src.data.preprocess

Step 2: Train Model

python -m src.models.train

Step 3: Start Backend Server

uvicorn api.app:app --reload

Step 4: Launch Frontend

  • Open frontend/index.html in your browser
  • Allow camera access
  • Start detecting emotions 🎉

Web Browser Version With Shell

Enable Script Execution

chmod +x shellscript.sh   

Run Full Pipeline (Preprocess + Train + Launch)

./shellscript.sh

Model Details

  • Input: 48×48 grayscale face images
  • Architecture: Lightweight CNN
  • Classes:
    • Angry
    • Disgust
    • Fear
    • Happy
    • Sad
    • Surprise
    • Neutral

Features

  • Real-time emotion detection
  • Lightweight CNN (fast inference)
  • Works with webcam + browser
  • FastAPI backend for scalable deployment

Notes

  • Ensure your webcam is accessible
  • Backend must be running before opening the frontend
  • Model file (final_emotion_model.keras) must exist in model_artifacts
  • Backend will be deployed using Render and Frontend with Vercel

Explore related projects

Loading…