Tiamat-Tech / Anime-Face-GAN

An effort to generate new anime faces using a DCGAN

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Anime-Face-GAN

Generating anime faces using a Deep Convolutional Generative Adversarial Network (DCGAN).
Here are a few images generated by the DCGAN ⬇️

Dataset used

The dataset is taken from Kaggle over here. The data was obtained from www.getchu.com and processed using a face detector based on the repo https://github.com/nagadomi/lbpcascade_animeface. The dataset contains images of size 64 by 64 pixels.

Objective 🎯

  • The objective of the project is to generate images of Anime faces using a Deep Convolutional GAN.
  • The DCGAN has two networks, the 'generator' and the 'discriminator'.
  • The generator takes in a random vector which then uses transposed convolutions to generate an image out of it.
  • The discriminator is a Convolutional network which then classifies whether an image is real or fake. It takes in samples of images from the dataset and also images generated by the generator.
  • Both networks try to improve each other's performance through backpropagation.

Architecture used

The architecture is inspired by the original DCGAN paper. However 'one-sided label smoothing' has been added to prevent the discriminator from overpowering the generator. The weights for the generator and discriminator can be found here

Generator

The generator takes in a 128 dimensional noise vector sampled from a normal distribution of zero mean and unit variance N(0,1). It is then followed by a Dense layer of 4x4x1024 units and reshaped to (4,4,1024).
Then a few transposed convolutional layers are followed which then results in an image of size (64,64,3) with pixel values of the range [-1,1] due to a tanh activation.

Discriminator

The discriminator is similar to a image classification CNN which takes in an image and outputs the probability of it being real.

Progress

Requirements βœ…

  • python 3.8.5
  • Anaconda 4.9.2+

Note: for running on a GPU instance you will require to download the respective CUDA and cuDNN (if the GPU present is CUDA compatible) versions to work with tensorflow. CUDA compatibility can be checked here

Instructions πŸ“ (For testing on CPU)

  • Clone the repository
  • Download the dataset from here into the same directory as the cloned repo (only required if training from scratch)
  • Download the trained weights from here for testing
  • Open anaconda prompt and cd into the repo
  • Run conda env create -f environment.yml
  • Run conda activate DCGAN
  • Run python -m ipykernel install --user --name=DCGAN to list it in the jupyter notebook's kernels. (Run conda install -c anaconda ipykernel in case ipykernel not installed)
  • Run jupyter notebook and make sure you are using the kernel 'DCGAN'
  • Run the notebook DCGAN.ipynb

Note: It is advised to train the model on a GPU. Training on a CPU can be time consuming.

Acknowledgements

Libraries used

About

An effort to generate new anime faces using a DCGAN


Languages

Language:Jupyter Notebook 99.7%Language:Python 0.3%