This repository contains a research-oriented PyTorch framework for Facial Expression Recognition (FER), developed as part of the Software Engineering Project (SEP) in the course Computer Vision & Deep Learning.
The goal of this project is to provide a clean, modular, and reproducible framework for:
- Developing and evaluating deep learning architectures for FER
- Designing structured pre-processing pipelines
- Running standardized training, evaluation, and inference
- Enabling image-based classification and video-based FER with explainability (XAI)
Facial Expression Recognition (FER) is a computer vision task that aims to automatically classify human emotions from facial images or video frames.
Typical emotion classes include:
- anger
- disgust
- fear
- happiness
- sadness
- surprise
FER is used in areas such as:
- Human-computer interaction
- Affective computing
- Behavioral analysis
- Robotics and AI systems
In this project, we implement and evaluate CNN-based and hybrid deep learning models, structured preprocessing pipelines, and explainability techniques such as Grad-CAM.
vision_lab/
├── README.md
├── requirements.txt
├── .env.example
├── docs/ # User docs: setup flow, preprocessing, training, inference
├── main/ # Python package + executable scripts
│ ├── pyproject.toml
│ ├── src/fer/
│ │ ├── config/ # Config defaults and override parsing
│ │ ├── dataset/ # Dataset loading utilities
│ │ ├── models/ # FER model implementations + factory/registry
│ │ ├── training/ # Training runner, losses, schedules, artifacts
│ │ ├── engine/ # Trainer/evaluator/checkpoint logic
│ │ ├── metrics/ # Classification and confusion metrics
│ │ ├── inference/ # Inference wrappers/hub models
│ │ ├── pre_processing/ # Normalization and augmentation utilities
│ │ ├── xai/ # Grad-CAM, occlusion, layer-activation tools
│ │ ├── cli/ # CLI package entry points
│ │ └── utils/ # Shared helpers
│ ├── scripts/ # Standalone scripts (train, download, livecam, XAI)
│ ├── weights/ # Local packaged weights/modules
│ └── xai_results/ # Generated XAI outputs
├── jobs/ # SLURM job files for many model/training variants
├── training_output/ # Experiment artifacts and run index
│ ├── runs/
│ └── runs_index.csv
├── testing/ # Evaluation and dataset utility scripts
├── demo/ # Local demo runner and instructions
├── classification_model/ # Local image-classification inference entrypoint
├── submission/ # Final submission-ready copies (demo + classification)
├── reports/ # Report outputs/notes
├── prepare_images_raw.slurm # Data preparation SLURM entrypoint
├── download_sources.slurm # Dataset/source download SLURM entrypoint
├── ferplus_labels.csv
└── rafdb_labels.txt
Notes:
- Core source code is under
main/src/fer. jobs/holds cluster execution configs, whiletraining_output/stores produced run artifacts.submission/mirrors runnable deliverables for handoff.
Please execute the following steps in order.
git clone https://github.com/dr-ramix/vision_lab.git
cd vision_lab# create
python -m venv venv
python3 -m venv venv
# activate (bash / sh / zsh)
source venv/bin/activate
. venv/bin/activate
# activate (fish)
source venv/bin/activate.fish
# activate (csh / tcsh)
source venv/bin/activate.csh# create
python -m venv venv
py -m venv venv
# activate (standard)
venv\Scripts\Activate.ps1
# activate (explicit relative path, often required)
.\venv\Scripts\Activate.ps1
# if execution policy blocks activation (temporary fix)
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\venv\Scripts\Activate.ps1:: create
python -m venv venv
py -m venv venv
:: activate
venv\Scripts\activate.bat# create
python -m venv venv
py -m venv venv
# activate
source venv/Scripts/activatedeactivatepip install -r requirements.txtcd main
pip install -e .This installs the fer package in editable mode.
python -c "import fer; print('OK')"If successful, it should print:
OK
Inside the submission/ directory you will find:
Path:
submission/classification_model/
Documentation:
instructions_classification_model.md
This explains:
- How to run image-based classification
- How to perform inference on a folder of images
- How to use pretrained weights
Path:
submission/demo/
Documentation:
instructions_video_demo.md
This explains:
- How to run video-based facial emotion recognition
- How to apply explainability methods (e.g., Grad-CAM)
- How to generate predictions with visual explanations
After the installation is complete, you must:
- Download the required datasets
- Configure the
.envfile - Run the preprocessing pipeline
All detailed instructions are documented in:
docs/pre_processing.md
Follow the steps there carefully and in the specified order.
This repository provides:
- A modular FER research framework
- Reproducible experiments
- Extendable model architectures
- Structured preprocessing
- Clear separation between training, evaluation, and inference
- A practical demonstration of explainable AI in FER