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)
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
python -m venv venvWindows:
venv\Scripts\activateMac/Linux:
source venv/bin/activatepip install -r requirements.txt
pip install -r requirements-dev.txtpython -m src.data.preprocesspython -m src.models.trainpython -m src.inference.webcampython -m src.data.preprocesspython -m src.models.trainuvicorn api.app:app --reload- Open
frontend/index.htmlin your browser - Allow camera access
- Start detecting emotions 🎉
chmod +x shellscript.sh ./shellscript.sh- Input: 48×48 grayscale face images
- Architecture: Lightweight CNN
- Classes:
- Angry
- Disgust
- Fear
- Happy
- Sad
- Surprise
- Neutral
- Real-time emotion detection
- Lightweight CNN (fast inference)
- Works with webcam + browser
- FastAPI backend for scalable deployment
- 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