Giter Site home page Giter Site logo

moeinh77 / simpson-face-generator-dcgan-pytorch Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 0.0 2.57 MB

Generating simpson faces using Deep Convolutional Generative Adversarial Networks, written in PyTorch.

Jupyter Notebook 100.00%
gan generative-adversarial-network cnn convolutional-neural-networks pytorch dcgan dcgan-pytorch simpsons-dcgan

simpson-face-generator-dcgan-pytorch's Introduction

Generating simpson faces using Deep Convolutional Generative Adversarial Networks.

GANs are a framework for teaching a DL model to capture the training data’s distribution so we can generate new data from that same distribution. I trained deep convolutional generative adversarial networks on a dataset of simpson faces to generate new faces based on the training samples.

Epoch 1 to 350 in one look:

Dataset:

https://www.kaggle.com/kostastokis/simpsons-faces 9877 Simpsons faces, extracted from seasons 25-28, all in 200x200 resolution and each centered on a single face.

Model:

The model includes a disciminator model which is made of convolution stages (Conv2d, BatchNorm, LeakyRelu) and a generator model with transpose convolution stages (TransposeConv2d, BatchNorm, LeakyRelu). The disciminator has 5 of such stages each with different number of convlayers and a fully connected layer at the end, and the generator is made up of 4 such transpose convolution stages and a convolution stage at the end. The negative slope of LeakyRelu is 0.2.

How to make the DCGAN work:

There were a lot of tricky details for getting the DCGAN generate some sharp looking pictures. Some of the hacks I used:

  • Using 0 as the label for the true class and 1 for fake labels for optimizer. Helps the optimizer to make better updates at the first couple of epochs.
  • Smoothing the labels. Instead of 1 i used random numbers in range of [0.7,1.2] and instead of 0 range of [0,0.3]. Prevents the optimizer from reaching loss 0.
  • Using noisy labels. I flipped the labels of 5% of the data.
  • Not using any pooling layer. Down sampling is done using stride of 2 in each convolutional layer.
  • Using large number of large-sized filters of 5x5.
  • Using the 0.0002 leanring rate for both generator and discriminator.
  • Using small batch size of 32. Helps the generator and discriminator to learn at the same pace.

Find out more about the hacks here:

My favorite generated pictures:

  • The one on the left looks like the chicken version of the simposons :)
  • 2 Mouths one on the neck :)
  • Pre-historic look !
  • Father+Son (Punk homer)

simpson-face-generator-dcgan-pytorch's People

Contributors

moeinh77 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.