Learn practical skills, build real-world projects, and advance your career

Training a Convolutional Neural Network to Recognize Facial Expressions- Zero to Gans Course Project

For my course project I have decided to train a cnn to differentiate facial expressions using a dataset containing six different classes of expressions.

I found this dataset on kaggle, and it represents an image classification problem; since the data consists of six classes with each class containing between ~3000-~7000 images.**

Importing the libraries and getting the dataset:

!pip install jovian --upgrade -q
!pip install torch===1.7.1+cu110 torchvision===0.8.2+cu110 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
Looking in links: https://download.pytorch.org/whl/torch_stable.html Collecting torch===1.7.1+cu110 Using cached https://download.pytorch.org/whl/cu110/torch-1.7.1%2Bcu110-cp39-cp39-win_amd64.whl (2050.2 MB) Requirement already satisfied: numpy in c:\users\geralt\appdata\local\programs\python\python39\lib\site-packages (from torch===1.7.1+cu110) (1.19.5) Collecting torchaudio===0.7.2 Downloading https://download.pytorch.org/whl/torchaudio-0.7.2-cp39-none-win_amd64.whl (103 kB) Collecting torchvision===0.8.2+cu110 Downloading https://download.pytorch.org/whl/cu110/torchvision-0.8.2%2Bcu110-cp39-cp39-win_amd64.whl (1.6 MB) Requirement already satisfied: pillow>=4.1.1 in c:\users\geralt\appdata\local\programs\python\python39\lib\site-packages (from torchvision===0.8.2+cu110) (8.1.0) Collecting typing-extensions Downloading typing_extensions-3.7.4.3-py3-none-any.whl (22 kB) Installing collected packages: typing-extensions, torch, torchvision, torchaudio Successfully installed torch-1.7.1+cu110 torchaudio-0.7.2 torchvision-0.8.2+cu110 typing-extensions-3.7.4.3
!pip install seaborn
Collecting seaborn Downloading seaborn-0.11.1-py3-none-any.whl (285 kB) Requirement already satisfied: numpy>=1.15 in c:\users\geralt\appdata\local\programs\python\python39\lib\site-packages (from seaborn) (1.19.5) Requirement already satisfied: matplotlib>=2.2 in c:\users\geralt\appdata\local\programs\python\python39\lib\site-packages (from seaborn) (3.3.3) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in c:\users\geralt\appdata\local\programs\python\python39\lib\site-packages (from matplotlib>=2.2->seaborn) (2.4.7) Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\geralt\appdata\local\programs\python\python39\lib\site-packages (from matplotlib>=2.2->seaborn) (1.3.1) Requirement already satisfied: cycler>=0.10 in c:\users\geralt\appdata\local\programs\python\python39\lib\site-packages (from matplotlib>=2.2->seaborn) (0.10.0) Requirement already satisfied: pillow>=6.2.0 in c:\users\geralt\appdata\local\programs\python\python39\lib\site-packages (from matplotlib>=2.2->seaborn) (8.1.0) Requirement already satisfied: python-dateutil>=2.1 in c:\users\geralt\appdata\roaming\python\python39\site-packages (from matplotlib>=2.2->seaborn) (2.8.1) Requirement already satisfied: six in c:\users\geralt\appdata\roaming\python\python39\site-packages (from cycler>=0.10->matplotlib>=2.2->seaborn) (1.15.0) Collecting pandas>=0.23 Downloading pandas-1.2.0-cp39-cp39-win_amd64.whl (9.3 MB) Collecting pytz>=2017.3 Downloading pytz-2020.5-py2.py3-none-any.whl (510 kB) Collecting scipy>=1.0 Downloading scipy-1.6.0-cp39-cp39-win_amd64.whl (32.7 MB) Installing collected packages: pytz, scipy, pandas, seaborn Successfully installed pandas-1.2.0 pytz-2020.5 scipy-1.6.0 seaborn-0.11.1