DeepFER is a TensorFlow/Keras facial emotion classifier with a CNN baseline, optional MobileNetV2 transfer learning, OpenCV inference, and a Flask interface.
Use Python 3.11, create a virtual environment, then install dependencies:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txttrain.py automatically checks dataset/; if it is not present, it finds the largest ZIP in the project and extracts it. It supports train/<emotion> and test/<emotion> layouts and checks that Angry, Disgust, Fear, Happy, Neutral, Sad, and Surprise are all available. A scan validates image readability and prints a count by split and class before training.
python train.py --model cnn --epochs 50 --batch-size 64
python train.py --model mobilenetv2 --epochs 20The best checkpoint is models/best_model.keras; plots and metrics are written to artifacts/. TensorBoard logs are under artifacts/tensorboard.
python predict.py --image path\to\face.jpg
python predict.py --video path\to\input.mp4 --output artifacts\result.mp4
python predict.py --webcamVideo and webcam output overlays the detected face emotion, confidence, and FPS. Press Q to leave webcam mode.
Train a model first, then run python app.py and open http://localhost:5000. The app has image and video upload views, a live-webcam instruction, result view, /predict, /predict_video, and /health endpoints.
docker compose up --buildThe Docker volume mounts preserve models/ and generated artifacts/.