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

🎥 Celebrity GAN 🎬 ⇨ Faces generated from celebrity faces

Video of Results from 100 Epochs

The CelebA Dataset:

This collection contains over 200,000 images of more than 10,000 different celebrities, which were all obtained from sources on the internet. The set has a great deal of variation in color, poses, composition, facial expression, styles, etc. My goal in choosing this dataset was to create a project that was quite challenging but at the same time possible to get an interesting and successful result. Before this dataset, I tried using 13,000+ impressionist paintings with GANs, which was very disappointing due to the vastness of the subject matter as well as the vagueness of the style. Compared to that challenge, which I had underestimated, this set seemed like it would offer a lot to work with but also generate images with few enough epochs as to be feasible.

The Process:

In this project, I train the model 3 different times (I trained many times aside from these to practice working with the data). The first training is for 44 epochs, which yielded quite good results, once I found a good learning rate and got the model training set up well. The second training here, which is for 200 epochs, suffered a great problem around epoch 45. Since I was training over night (as this model takes an extremely long time to train per epoch), I did not catch the issue. I woke up to a very disappointing reality that over 3/4 of the training was useless. So I adjusted the hyperparameters yet again and tried for a 100 epoch training, which turned out very good.

⇓ Importing all the necessary libraries:

from __future__ import print_function
import argparse
import os
import random
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim as optim
import torch.utils.data
import torchvision.datasets as Dataset
import torchvision.transforms.functional as TF
import torchvision.transforms as T
import torchvision.utils as TVU
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as ani
from IPython.display import HTML
import PIL
%matplotlib inline

⇓ Defining important variables: