项目作者: huangzehao

项目描述 :
torch implementation of srgan
高级语言: Lua
项目地址: git://github.com/huangzehao/torch-srgan.git
创建时间: 2016-11-14T09:22:44Z
项目社区:https://github.com/huangzehao/torch-srgan

开源协议:MIT License

下载


torch-srgan

This code only provides the implementation of SRResNet. SRGAN is implemented but the result is not very good.

Torch implementation of Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network that generates high-resolution images from low-resolution input images, for example:

Setup

Prerequisites

  • Linux
  • NVIDIA GPU + CUDA CuDNN
  • Python with Numpy, Scipy, PIL, h5py
  • Torch with nn, image, graphicsmagick, trepl, hdf5, cunn, cutorch

Getting Started

  • Clone this repo:
    1. git clone https://github.com/huangzehao/torch-srgan
    2. cd torch-srgan

    Train

  • Download imagenet valset for training

  • Prepare training data

    1. python make_data.py --train_dir $(train_data_folder) --val_dir $(val_data_folder) --output_file $(output_hdf5_file)
  • (Optional) Download VGG19 model for perceptual training
    1. cd models
    2. bash VGG19.sh
  • Train the model
    1. mkdir checkpoint val
    2. # SRResNet MSE
    3. CUDA_VISIBLE_DEVICES=0 th train.lua -h5_file $(output_hdf5_file) -num_epoch 50 -loss 'pixel'
    4. # SRResNet MSE VGG22 (need VGG19 model)
    5. CUDA_VISIBLE_DEVICES=0 th train.lua -h5_file $(output_hdf5_file) -num_epoch 50 -loss 'percep' -percep_layer 'conv2_2' -use_tanh
    6. # SRResNet MSE VGG54 (need VGG19 model)
    7. CUDA_VISIBLE_DEVICES=0 th train.lua -h5_file $(output_hdf5_file) -num_epoch 50 -loss 'percep' -percep_layer 'conv5_4' -use_tanh

    Test

  • Test trained model
    1. # SRResNet MSE
    2. CUDA_VISIBLE_DEVICES=0 th test.lua -img ./imgs/comic_input.bmp -output ./output.bmp -model ./models/SRResNet_MSE_100.t7
    3. # SRResNet MSE VGG22
    4. CUDA_VISIBLE_DEVICES=0 th test.lua -img ./imgs/comic_input.bmp -output ./output.bmp -model ./models/SRResNet_MSE_VGG22_100.t7 -use_tanh
    5. # SRResNet MSE VGG54
    6. CUDA_VISIBLE_DEVICES=0 th test.lua -img ./imgs/comic_input.bmp -output ./output.bmp -model ./models/SRResNet_MSE_VGG54_100.t7 -use_tanh

Acknowledgments

Code borrows heavily from fast-neural-style and cifar.torch. Thanks for their excellent work!