Coder Social home page Coder Social logo

caomw / gp-gan Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wuhuikai/gp-gan

0.0 2.0 0.0 17.66 MB

Official Chainer implementation of GP-GAN: Towards Realistic High-Resolution Image Blending

License: MIT License

MATLAB 89.68% Python 9.31% Shell 0.06% HTML 0.95%

gp-gan's Introduction

GP-GAN: Towards Realistic High-Resolution Image Blending

[Project] [Paper]
Official Chainer implementation of GP-GAN: Towards Realistic High-Resolution Image Blending

Overview

source destination mask composited blended

GP-GAN (aka. Gaussian-Poisson GAN) is the author's implementation of the high-resolution image blending algorithm described in:
"GP-GAN: Towards Realistic High-Resolution Image Blending"
Huikai Wu, Shuai Zheng, Junge Zhang, Kaiqi Huang

Given a source image, a destination image and a mask, our algorithm could blend the two images given the mask and generate high-resolution and realsitic results. Our algorithm is based on deep generative models such as Wasserstein GAN.

Contact: Hui-Kai Wu ([email protected])

Getting started

  • Install the python libraries. (See Requirements).
  • Download the code from GitHub:
git clone https://github.com/wuhuikai/GP-GAN.git
cd GP-GAN
  • Download the pretrained models blending_gan.npz and unsupervised_blending_gan.npz from Google Drive, then put them in models.

  • Run the python script:

python run_gp_gan.py --src_image images/test_images/src.jpg --dst_image images/test_images/dst.jpg --mask_image images/test_images/mask.png --blended_image images/test_images/result.png

Results compared with baseline methods

Mask Copy-and-Paste Modified-Poisson Multi-splines Supervised GP-GAN Unsupervised GP-GAN

Requirements

The code is written in Python3.5 and requires the following 3rd party libraries:

pip install git+git://github.com/mila-udem/fuel.git

Details see the official README for installing fuel.

pip install scikit-image

Details see the official README for installing skimage.

pip install chainer

Details see the official README for installing Chainer.

Command line arguments:

Type python run_gp_gan.py --help for a complete list of the arguments.

  • --supervised: use unsupervised Blending GAN if set to False
  • --list_path: process batch of images according to the list

Step by step from scratch

Training Blending GAN

  • Download Transient Attributes Dataset, see the project website for more details.
  • Crop the images in each subfolder:
python crop_aligned_images.py --data_root [Path for imageAlignedLD in Transient Attributes Dataset]
  • Train Blending GAN:
python train_blending_gan.py --data_root [Path for cropped aligned images of Transient Attributes Dataset]
  • Training Curve

  • Result
Training Set Validation Set

Training Unsupervised Blending GAN

  • Download the hdf5 dataset of outdoor natural images: ourdoor_64.hdf5 (1.4G), which contains 150K landscape images from MIT Places dataset.
  • Train unsupervised Blending GAN:
python train_wasserstein_gan.py --data_root [Path for outdoor_64.hdf5]
  • Training Curve

  • Samples after training

NOTE: Type python [SCRIPT_NAME].py --help for more details about the arguments.

Object-level annotation for Transient Attributes Dataset (used for mask images)

  • The folder name on LabelMe is /transient_attributes_101
  • The processed masks are in the folder mask on this repository
  • Coresponding scripts for processing raw xmls from LabelMe are also in the folder mask

Evaluate blended results using RealismCNN

Get pretrained realismCNN

Download pretrained caffe model and transform it to Chainer model:

python load_caffe_model.py

Or Download pretrained Chainer model directly.

Evalute the blended images

python predict_realism.py --list_path [List File]

User Study

Set up image server

  • Install lighttgb:
sudo apt-get install lighttpd
  • Start server by running the script in folder user_study:
sh light_tpd_server.sh [Image Folder] [Port]

Template for user study

See [user_study.html] in folder user_study for details.

Baseline Methods

Code for baseline methods can be downloaded from here.

Also, the modified code for baseline methods is in folder Baseline.

TODO

  • Experiment with more gradient operators like Sobel or egde detectors like Canny.
  • Add more constraints for optimizing z vector like Perception Loss.
  • Try different losses like CNN-MRF.

Citation

@article{wu2017gp,
  title={GP-GAN: Towards Realistic High-Resolution Image Blending},
  author={Wu, Huikai and Zheng, Shuai and Zhang, Junge and Huang, Kaiqi},
  journal={arXiv preprint arXiv:1703.07195},
  year={2017}
}

gp-gan's People

Contributors

wuhuikai 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.