This academic project uses Convolutional Neural Networks (CNNs) to classify facial emotions from images. The four emotion classes are: neutral, surprise, focused/engaged, and angry. The project also explores bias analysis by age (young, middle, senior).
The code has been modified to remove private or sensitive data, so you can run it with your own datasets.
- Main dataset: FER-2013 (for most classes)
- Folder structure:
Dataset/train
: training images for all classesDataset/age-bias-train
: used to test for age-related biasDataset/age
: additional images for bias mitigation
- Each subfolder represents one class.
- Languages: Python
- Libraries: PyTorch, Skorch, NumPy, scikit-learn, Matplotlib
- Clone the repository.
- Install dependencies:
pip install -r requirements.txt
cnnModel.py
: CNN architectures (CNN, CNNV1, CNNV2)train.py
: Train a model; outputs training logs, confusion matrix, and saves the best-fit modelevaluate.py
: Evaluate model performance and confusion matrix; supports k-fold cross-validationload.py
: Test model on single images or custom datasets
classDistribution.py
: Bar graph showing the number of images per classsampleimage.py
: Displays random images and histograms from each class
- Update
dataPath
andmodelPath
in the scripts. - Select the CNN architecture by commenting/uncommenting in
train.py
. - Run
train.py
to train the model. - Use
evaluate.py
orload.py
to test and analyze results.