GithubHelp home page GithubHelp logo

lbnphoenix / deep-feature-consistent-variational-autoencoder-in-tensorflow Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sbavon/deep-feature-consistent-variational-autoencoder-in-tensorflow

0.0 1.0 0.0 18.08 MB

implement Deep Feature Consisten Variational Autoencoder in Tensorflow

License: Apache License 2.0

Python 100.00%

deep-feature-consistent-variational-autoencoder-in-tensorflow's Introduction

Deep Feature Consistent Variational Autoencoder in Tensorflow

This repository has an objective to implement Deep Feature Consisten Variational Autoencoder (DFC-VAE) according to Deep Feature Consistent Variational Autoencoder. Tensorflow and Python3 are used for development, and pre-trained VGG16 is adapted from VGG in TensorFlow. The training data is CelebA dataset.

To understand this following note, I would recommend to know the concept of Variational Autoencoder and generative model.

Results

Generated Image Random Image interpolated Image

Figure 3: Interpolated image

Problem Statement

It is known that one major problem of plain Variational Autoencoder (Plain-VAE) is that images generated by the model are blurry. This is because the plain model's loss function is defined by pixel-wise comparison between input images and generated images. As a consequence, optimizing model to achieve a great performance is difficult because slightly shifting or distorting those images can result in a very high loss. In other words, even the images have just slight difference in human eyes, computer treats that a big difference!

distorted image

However, with DFC-VAE, the model leverages perceptual loss used in Neural Style Transfer. With regard to this paper, internal representations of convolutional neural networks could capture a content of the input image. This finding leads to the concept of perceptual loss, which compares the content - hidden representation - between images as oppose to calculate euclidean distant among pixels.

model architecture

Implementation

The solution contains four files

File Name Description
dfc_vae_model.py builds the VAE model, including encoder,decoder, VGG, loss function, and optimizer
train_dfc_vae.py trains the DFC_VAE model, and tests interpolation
vgg16.py builds the pre-trained VGG16 model
util.py contains supporting functions, such as data-preprocessing

Step-by-Step execution

Download and preprocess data

  1. Download pre-trained VGG weights from VGG in TensorFlow
  2. Download CelebA dataset from CelebA dataset
  3. Compress data in Zip
  4. Process images (crop and resize) and convert them to TFRecord format (refer to write_tfrecord() function in util.py)

Train the model

  1. Run train_dfc_vae.py

Dependencies

  • scipy.misc
  • zipfile (used for reading content inside Zip file)
  • imageio (used for generating .gif file)

Tips

  • Beta value is extremely significant. You need to adjust the value to make sure the model produce a great result
  • Save file in .png format for a better quality image

References

deep-feature-consistent-variational-autoencoder-in-tensorflow's People

Contributors

sbavon avatar

Watchers

James Cloos 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.