GithubHelp home page GithubHelp logo

alex-lechner / pytorch-gan Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 6.0 310.96 MB

Creating artificial images with a Generative Adversarial Network written in PyTorch.

Python 100.00%
generative-adversarial-network convolutional-neural-networks neural-network image-processing generative-art generative-model discriminator generator deep-learning deep-neural-networks deconvolution

pytorch-gan's Introduction

PyTorch-GAN


A Generative Adversarial Network is a technique to create artificial images with a Neural Network. The algorithm was invented by Ian Goodfellow and can be used for e.g. image enhancement, (artistic) style transfer, etc.

The GAN technique trains two Neural Networks simultaneously: A Generator network and a Discriminator network.

The Generator network is a Deconvolutional Neural Network which takes randomly generated noise as an input and returns a generated image as an output. The Discriminator network is Convolutional Neural Network which is trained on fake images from the Generator network and real images from a given dataset (CIFAR10 was used in this project). The goal of the Discriminator network is to distinguish between real and fake images. The goal of the Generator network is to trick the Discriminator network by generating realistic fake images.

gan-architecture

Source: A Beginner's Guide to Generative Adversarial Networks (GANs)

Installation

For this project, only the PyTorch library is needed. To install PyTorch visit the website and choose your specifications.

Training

To start training open navigate to the root folder of this project in your Command Line/Terminal and execute:

python dcgan.py

After each epoch, the current state of the Generator model and Discriminator model is saved. If you want to resume training at a given epoch you have to execute the following line:

python dcgan.py --resume_generator path/to/your-generator-model.pth --resume_discriminator path/to/your-discriminator-model.pth

To change the batch size simply change BATCH_SIZE = 64 in dcgan.py on line 18 to the size you want.

To change the number of epochs simply change EPOCH_SIZE = 25 in dcgan.py on line 20 to the number you want.

Result

After training the GAN for 25 epochs (which took nearly 1 day on my local machine) the Generator network is almost able to generate objects. Even though the objects are still a bit abstract you can already guess what the Generator network attempts to generate in some images.

gan-animation

GAN results after each epoch

pytorch-gan's People

Contributors

alex-lechner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.