Codi33 / VAE-pytorch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Variational Autoencoder

Implementation of VAE using Pytorch

Original Paper on VAE

Nice video explaining intuition behind it

Results below were achieved after training on these datasets:

VAE with discriminator

In order to increase sharpness of images generated by plain VAE, model called discriminator was added at the end of generation process. So in this case VAE can be viewed as a generator in a GAN model, which will have to optimize reconstruction loss and so-called adversarial loss simultaneously.

Plain VAE

Training

To train on your dataset specify path to it in config.py ROOT_DIR variable

Also you can tweak all the hyperparameters except for IMG_SIZE must be power of 2 (32, 64, 128, etc.) and images in dataset supposed to have equal length and width

After you are all set just run

python train_vae.py 

or

python train_vae_with_discriminator.py

in case you want sharper images to be generated after training

Generating images with pretrained models

There are four available models to generate images

Script below has some parameters which can be viewed with specifying -h

Without any of them it will just generate anime face with plain VAE and put it in generated_images directory

python generate_image.py

About

License:MIT License


Languages

Language:Python 100.0%