GithubHelp home page GithubHelp logo

crypto-code / variational-autoencoder Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 131.99 MB

Use a VAE to generate all new pokemons

License: MIT License

Python 100.00%
variational-autoencoders pokemons vaes image-generator image-generation moxiegushi

variational-autoencoder's Introduction

Variational Autoencoder

In contrast to the more standard uses of neural networks as regressors or classifiers, Variational Autoencoders (VAEs) are powerful generative models, now having applications as diverse as from generating fake human faces, to producing purely synthetic music.

How does a Variational Autoencoder work?

First, an encoder network turns the input samples x into two parameters in a latent space, which we will note z_mean and z_log_sigma. Then, we randomly sample similar points z from the latent normal distribution that is assumed to generate the data, via z = z_mean + exp(z_log_sigma) * epsilon, where epsilon is a random normal tensor. Finally, a decoder network maps these latent space points back to the original input data.

The parameters of the model are trained via two loss functions:

  • Reconstruction Loss forcing the decoded samples to match the initial inputs (just like normal autoencoders) [line 86]
  • KL divergence between the learned latent distribution and the prior distribution, acting as a regularization term. [line 87]

You could actually get rid of this latter term entirely, although it does help in learning well-formed latent spaces and reducing overfitting to the training data.

Requirements:

Usage

  • Download an image dataset, a pokemon dataset is already included (provided by moxiegushi)

  • Convert the Image colour scheme from RGBA to RGB by running,

python RGBA2RGB.py --help

usage: RGBA2RGB.py [-h] --input INPUT --output OUTPUT

Convert RGBA to RGB

optional arguments:
  -h, --help       show this help message and exit
  --input INPUT    Directory containing images to resize. eg: ./resized
  --output OUTPUT  Directory to save resized images. eg: ./RGB_data
  • Resize the image for input using the resize script,
python resize.py --help

usage: resize.py [-h] --input INPUT --output OUTPUT

Resize Input Images

optional arguments:
  -h, --help       show this help message and exit
  --input INPUT    Directory containing images to resize. eg: ./data
  --output OUTPUT  Directory to save resized images. eg: ./resized

  • Once the dataset is prepared you can run the VAE on it by using the vae script,
python vae.py --help

Using TensorFlow backend.
usage: vae.py [-h] --input INPUT [--epoch EPOCH] [--batch BATCH]
              [--inter_dim INTER_DIM]

Variational Autoencoder

optional arguments:
  -h, --help            show this help message and exit
  --input INPUT         Directory containing images eg: data/
  --epoch EPOCH         No of training iterations
  --batch BATCH         Batch Size
  --inter_dim INTER_DIM
                        Dimension of Intermediate Layer

Examples:

The images aren't perfect but do have a likeness to actual pokemons.

Credits

Thank you Jabrils for giving me the idea for this project. Thank you moxiegushi for providing me with the dataset.

G00D LUCK

For doubts email me at: [email protected]

variational-autoencoder's People

Contributors

crypto-code avatar

Stargazers

 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.