UE4/AI SHOWCASE

unreal engine 4

AI machine learning

In this project, I tried to apply what I learnt about how to build a simple convolutional neural network to implement a basic face recognition system in Python. To make the project more interesting, I create a dataset that consists of 200 images of faces from 10 family members and friends of mine. Then I implement a simple convolutional neural network using PyTorch and get 73% of accuracy on the validation set!

To create a customized face dataset, I retrieved hundreds of images taken with my family and friends from my phone and used a powerful library called “dlib” to help me crop out all the faces in those images and saved a huge amount of tedious manual labour, as shown in the “crop_face.py” file. After I get a bunch of face images, I manually classify them into 10 classes, with each class containing 20 images. Finally, I randomly split the dataset into a training set and a validation set for the sake of evaluation.

After I had my dataset built, I implemented a convolutional neural network in Python with PyTorch, as shown in the “my_face_recognition.py” file. Firstly, I built a PyTorch customized dataset loader to read images from my face dataset and enable the iteration during the training process. Then a model with 3 convolution layers and 1 hidden layer was constructed to “read” these images and make predictions. Finally, I adopted Cross-entropy loss as the loss function and stochastic gradient descent as the optimizing algorithm to train the model in 50 epochs. During the training process, I evaluate both the training accuracy, validation accuracy and the confusion matrix on the validation set for every epoch to observe the performance of my model.

To achieve best performance, I tuned some hyper-parameters in the model such as the number of channels in convolutional layers and the number of neurons in the hidden layers and and finally, I get the best accuracy of 76.67%. The best model contains two convolutional layers with 32 features with a 3*3 kernel, followed by another layer with 64 features with 3*3 kernel, and a hidden layer with 100 neurons and finally an output layer with 10 neurons.