Giter VIP home page Giter VIP logo

shift-net's Introduction

Architecutre

Shift layer

Shift-Net

Please refer to our code Shift-Net_pytorch based on Pytorch. It is much faster than this repository. As some code in this repository is implemented using for-loop, while the code of pytorch version Shift-Net_pytorch is fully-implemented parallelly.

Pytorch version: 8ms a 256*256 image for reference

Torch version: 80ms a 256*256 image for reference

So we strongly suggest you have a look at our pytorch version.

Getting Started

We expect you have an nvidia GPU and have installed CUDA. The code does not support running on CPU for now.

Installation

luarocks install nngraph
luarocks install cudnn
luarocks install https://raw.githubusercontent.com/szym/display/master/display-scm-0.rockspec
  • Clone this repo:
git clone https://github.com/Zhaoyi-Yan/Shift-Net
cd Shift-Net

Download pre-trained model

bash  scripts/download_models.sh

The model will be downloaded and unzipped. If you cannot have access to OneDrive, then you can try BaiduCloud to download our model.

Train

  • Download your own dataset.

  • Change the options in train.lua according to your path of dataset. Normally, you should at least specify three options. They are DATA_ROOT, phase and name.

For example:

DATA_ROOT: ./datasets/Paris_StreetView_Dataset/

phase: paris_train

name: paris_train_shiftNet

This means that the training images are under the folder of ./datasets/Paris_StreetView_Dataset/paris_train/. As for name, it gives your experiment a name, e.g., paris_train_shiftNet. When training, the checkpoints are stored under the folder ./checkpoints/paris_train_shiftNet/.

  • Train a model:
th train.lua
  • Display the temporary results on the browser. Set display = 1, and then open another console,
th -ldisplay.start
  • Open this URL in your browser: http://localhost:8000

  • If you want to train a model that can handle random mask inpainting, then set

mask_type: 'random'

fixed_mask: false

You can set a float number to res, e.g., local res = 0.06, the lower it is, the more continuous the output will be. When test the model, these two options should keep consistent with those that you model are trained with.

Test

Before test, you should change DATA_ROOT, phase, name, checkpoint_dir and which_epoch. For example, if you want to test the 30-th epoch of your trained model, then

DATA_ROOT: ./datasets/Paris_StreetView_Dataset/

phase: paris_train

name: paris_train_shiftNet

checkpoint_dir:./checkpoints/

which_epoch: '30'

The first two options determine where the dataset is, and the rest define the folder where the model is stored.

  • Finally, test the model:
th test.lua

If you find this paper useful, please cite:

@InProceedings{Yan_2018_Shift,
author = {Yan, Zhaoyi and Li, Xiaoming and Li, Mu and Zuo, Wangmeng and Shan, Shiguang},
title = {Shift-Net: Image Inpainting via Deep Feature Rearrangement},
booktitle = {The European Conference on Computer Vision (ECCV)},
month = {September},
year = {2018}
}

Acknowledgments

We benefit a lot from pix2pix and DCGAN. The data loader is modified from pix2pix and the implemetation of Instance Normalization borrows from Instance Normalization. The shift operation is inspired by style-swap.

shift-net's People

Contributors

zhaoyi-yan 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.