So, let’s see the code I used to get it working.
First of all, I needed a training dataset. For that, I created a set of face images of 10 subjects with around 500 images each.
![]() |
| The training dataset (yep, that's my face) |
I use a file naming convention as <subject_label>-<subject_name>-<unique_number>.jpg (e.g. 0-Thimira-1475137898.65.jpg) for the training images to make it easier to read in and get the metadata of the images in one go. (I will do a separate post on how to easily create training datasets of face images like this).
We'll mainly be using Keras to build the model, and scikit-learn for some utility functions. We’ll need to import the following packages,
from sklearn.cross_validation import train_test_split
from keras.optimizers import SGD
from keras.utils import np_utils
import numpy as np
import argparse
import cv2
import os
import sys
from PIL import Image



