Torch Implementation of "Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network"

Overview

Photo-Realistic-Super-Resoluton

Torch Implementation of "Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network" [Paper]

This is a prototype implementation developed by Harry Yang.

Getting started

####Training prepare your images under a sub-folder of a root folder

t_folder=your_root_folder model_folder=your_save_folder/ th run_sr.lua 

By default it resizes the images to 96x96 as ground truth and 24x24 as input, but you can specify the size using loadSize. Note current generator network only supports 4x super-resolution. In addition, the input size must be dividable by 32 (such as 96, 128, 160, etc.).

By default it resizes the images to 96x96 as ground truth and 24x24 as input, but you can specify the size using loadSize and scale.

####Loading a saved model to train

D_path=your_saved_D_model G_path=your_saved_G_model t_folder=your_root_folder model_folder=your_save_folder/ th run_resume.lua

####Testing prepare your test images under a sub-folder of a root folder

t_folder=your_root_folder model_file=your_G_model result_path=location_to_save_results th run_test.lua

Report Issues

Contact

Citation

If you find this code useful for your research, please cite:

@misc{Johnson2015,
  author = {Yang, Harry},
  title = {super-resolution using GAN},
  year = {2016},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/leehomyc/Photo-Realistic-Super-Resoluton}},
}
Comments
  • Some questions on this implementation

    Some questions on this implementation

    Hi,

    This paper is interesting. Thanks for your implementation!

    I mainly have two questions. In line 28 of your adversarial_G.lua file, your wrote: "nn.Sequential():add(nn.ConcatTable():add(netG):add(nn.Identity())):add(nn.CAddTable(true))".

    I'm wondering where is the netG? Is this line a mistake?

    BTW, in the original paper, there's no relu function for the second conv in each residual block. In your implementation, it seems you add relu for each second conv in residual blocks.

    opened by tyshiwo 3
  • can u share your trained model?

    can u share your trained model?

    Dear sir: This paper is interesting. Thanks for your implementation! I have some learning need now,can u share your trained model.if can ,I must be give you much thanks!

    opened by crazyzsy 0
  • I can't run run_sr.lua

    I can't run run_sr.lua

    The following is my mistake:

    t_folder=dataset/ model_folder=model/ th run_sr.lua { ntrain : inf beta1 : 0.9 name : "super_resolution" dataset : "folder" niter : 250 lr : 0.001 model_folder : "model/" gpu : 1 nThreads : 4 t_folder : "dataset/" batchSize : 32 loadSize : 96 } Starting donkey with id: 1 seed: 1 table: 0x40c0e918 Starting donkey with id: 3 seed: 3 table: 0x41c70418 Starting donkey with id: 4 seed: 4 table: 0x410d8418 Starting donkey with id: 2 seed: 2 table: 0x41b53db0 Creating train metadata table: 0x41632658 Creating train metadata table: 0x410d8a28 Creating train metadata table: 0x40222228 Creating train metadata table: 0x40c0ebf0 running "find" on each class directory, and concatenate all those filenames into a single file containing all image paths for a given class now combine all the files to a single large file running "find" on each class directory, and concatenate all those filenames into a single file containing all image paths for a given class load the large concatenated list of sample paths to self.imagePath now combine all the files to a single large file load the large concatenated list of sample paths to self.imagePath running "find" on each class directory, and concatenate all those filenames into a single file containing all image paths for a given class now combine all the files to a single large file load the large concatenated list of sample paths to self.imagePath /root/torch/install/bin/luajit: /root/torch/install/share/lua/5.1/threads/threads.lua:183: [thread 4 callback] .../Photo-Realistic-Super-Resoluton-master/data/dataset.lua:210: Could not find any image file in the given input paths stack traceback: [C]: in function 'assert' .../Photo-Realistic-Super-Resoluton-master/data/dataset.lua:210: in function '__init' /root/torch/install/share/lua/5.1/torch/init.lua:91: in function </root/torch/install/share/lua/5.1/torch/init.lua:87> [C]: in function 'dataLoader' ...tic-Super-Resoluton-master/data/donkey_folder_supres.lua:69: in main chunk [C]: in function 'dofile' /home/Photo-Realistic-Super-Resoluton-master/data/data.lua:33: in function </home/Photo-Realistic-Super-Resoluton-master/data/data.lua:23> [C]: in function 'xpcall' /root/torch/install/share/lua/5.1/threads/threads.lua:234: in function 'callback' /root/torch/install/share/lua/5.1/threads/queue.lua:65: in function </root/torch/install/share/lua/5.1/threads/queue.lua:41> [C]: in function 'pcall' /root/torch/install/share/lua/5.1/threads/queue.lua:40: in function 'dojob' [string " local Queue = require 'threads.queue'..."]:13: in main chunk stack traceback: [C]: in function 'error' /root/torch/install/share/lua/5.1/threads/threads.lua:183: in function 'dojob' /root/torch/install/share/lua/5.1/threads/threads.lua:264: in function 'synchronize' /root/torch/install/share/lua/5.1/threads/threads.lua:142: in function 'specific' /root/torch/install/share/lua/5.1/threads/threads.lua:125: in function 'Threads' /home/Photo-Realistic-Super-Resoluton-master/data/data.lua:21: in function 'new' run_sr.lua:31: in main chunk [C]: in function 'dofile' /root/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk [C]: at 0x00406670

    I'm sure I have the training data I need in my catalog. Can you help me?

    opened by FIGHTFORGLO 1
  • Do you have some model to test ?

    Do you have some model to test ?

    Dear Sir, I train the code which you submited with ImageNet on epoch 3, but didn't have good performance. Would you please give some model to compare?

           Thank you very much for your reply.
    
    opened by hankobe 0
  • test image folder can not be reused

    test image folder can not be reused

    Hi~it's me again and this time I have met another problem =)

    The first time I run "t_folder=/xx/xx model_file=/xx/xx result_path=/xx/xx th run_test.lua" and it worked perfectly, which is nice, but after I change the test images under the same folder, it reminds me that a certain image file can not be found, the error info is like this:

    hannraoi@hannraoi-B85M-DS3H:~/Photo-Realistic-Super-Resoluton-master$ t_folder=/home/hannraoi/my_srgan_test/ model_file=/home/hannraoi/my_srgan_model/super_resolution_adversarial_G_134 result_path=/home/hannraoi/my_srgan_result/ th run_test.lua { niter : 250 dataset : "folder" ntrain : inf model_file : "/home/hannraoi/my_srgan_model/super_resolution_adversarial_G_134" t_folder : "/home/hannraoi/my_srgan_test/" batchSize : 32 result_path : "/home/hannraoi/my_srgan_result/" loadSize : 96 nThreads : 4 scale : 4 gpu : 1 } Starting donkey with id: 1 seed: 1 table: 0x7fd2180ff0a0 Starting donkey with id: 3 seed: 3 table: 0x7fd214129350 Starting donkey with id: 2 seed: 2 table: 0x7fd210128ad0 Starting donkey with id: 4 seed: 4 table: 0x7fd20c128da0 Loading train metadata from cache Loading train metadata from cache Loading train metadata from cache Loading train metadata from cache /home/hannraoi/torch/install/bin/lua: ...hannraoi/torch/install/share/lua/5.2/threads/threads.lua:183: [thread 2 callback] /home/hannraoi/torch/install/share/lua/5.2/image/init.lua:352: /home/hannraoi/my_srgan_test/subfolder/1b38b72e-af9c-4708-8e7d-5ba80d4a24ea.png: No such file or directory stack traceback: [C]: in function 'error' /home/hannraoi/torch/install/share/lua/5.2/image/init.lua:352: in function 'load' ...tic-Super-Resoluton-master/data/donkey_folder_supres.lua:35: in function 'loadImage' ...tic-Super-Resoluton-master/data/donkey_folder_supres.lua:50: in function <...tic-Super-Resoluton-master/data/donkey_folder_supres.lua:48> (...tail calls...) .../Photo-Realistic-Super-Resoluton-master/data/dataset.lua:354: in function <.../Photo-Realistic-Super-Resoluton-master/data/dataset.lua:347> (...tail calls...) [C]: in function 'xpcall' ...hannraoi/torch/install/share/lua/5.2/threads/threads.lua:234: in function 'callback' ...e/hannraoi/torch/install/share/lua/5.2/threads/queue.lua:65: in function <...e/hannraoi/torch/install/share/lua/5.2/threads/queue.lua:41> [C]: in function 'pcall' ...e/hannraoi/torch/install/share/lua/5.2/threads/queue.lua:40: in function 'dojob' [string " local Queue = require 'threads.queue'..."]:15: in main chunk stack traceback: [C]: in function 'error' ...hannraoi/torch/install/share/lua/5.2/threads/threads.lua:183: in function 'dojob' ...aoi/Photo-Realistic-Super-Resoluton-master/data/data.lua:76: in function 'getBatch' run_test.lua:33: in main chunk [C]: in function 'dofile' ...raoi/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk [C]: in ?

    I know little about Lua, so I don't know where the problem comes from, I hope to get some help, thanks!

    opened by hannraoi 3
  • How can you imporve the accuracy in last submittion, please?

    How can you imporve the accuracy in last submittion, please?

    Dear Sir,

    Thanks so much to your work, we are trying some new idea based your work. We have seen that you have submitted Feb 10 a new picture result with great improvement to previous one. Would you like to share your experience to achieve that, please?

    opened by WONG-Thomas 3
Owner
Harry Yang
Harry Yang
Torch implementation of "Enhanced Deep Residual Networks for Single Image Super-Resolution"

NTIRE2017 Super-resolution Challenge: SNU_CVLab Introduction This is our project repository for CVPR 2017 Workshop (2nd NTIRE). We, Team SNU_CVLab, (B

Bee Lim 625 Dec 30, 2022
Torch-ngp - A pytorch implementation of the hash encoder proposed in instant-ngp

HashGrid Encoder (WIP) A pytorch implementation of the HashGrid Encoder from ins

hawkey 1k Jan 1, 2023
Bayesian-Torch is a library of neural network layers and utilities extending the core of PyTorch to enable the user to perform stochastic variational inference in Bayesian deep neural networks

Bayesian-Torch is a library of neural network layers and utilities extending the core of PyTorch to enable the user to perform stochastic variational inference in Bayesian deep neural networks. Bayesian-Torch is designed to be flexible and seamless in extending a deterministic deep neural network architecture to corresponding Bayesian form by simply replacing the deterministic layers with Bayesian layers.

Intel Labs 210 Jan 4, 2023
A machine learning library for spiking neural networks. Supports training with both torch and jax pipelines, and deployment to neuromorphic hardware.

Rockpool Rockpool is a Python package for developing signal processing applications with spiking neural networks. Rockpool allows you to build network

SynSense 21 Dec 14, 2022
A torch.Tensor-like DataFrame library supporting multiple execution runtimes and Arrow as a common memory format

TorchArrow (Warning: Unstable Prototype) This is a prototype library currently under heavy development. It does not currently have stable releases, an

Facebook Research 536 Jan 6, 2023
Pytorch and Torch testing code of CartoonGAN

CartoonGAN-Test-Pytorch-Torch Pytorch and Torch testing code of CartoonGAN [Chen et al., CVPR18]. With the released pretrained models by the authors,

Yijun Li 642 Dec 27, 2022
Implements Stacked-RNN in numpy and torch with manual forward and backward functions

Recurrent Neural Networks Implements simple recurrent network and a stacked recurrent network in numpy and torch respectively. Both flavours implement

Vishal R 1 Nov 16, 2021
Torch-based tool for quantizing high-dimensional vectors using additive codebooks

Trainable multi-codebook quantization This repository implements a utility for use with PyTorch, and ideally GPUs, for training an efficient quantizer

Daniel Povey 41 Jan 7, 2023
Pytorch Implementations of large number classical backbone CNNs, data enhancement, torch loss, attention, visualization and some common algorithms.

Torch-template-for-deep-learning Pytorch implementations of some **classical backbone CNNs, data enhancement, torch loss, attention, visualization and

Li Shengyan 270 Dec 31, 2022
Torch-mutable-modules - Use in-place and assignment operations on PyTorch module parameters with support for autograd

Torch Mutable Modules Use in-place and assignment operations on PyTorch module p

Kento Nishi 7 Jun 6, 2022
Sharpened cosine similarity torch - A Sharpened Cosine Similarity layer for PyTorch

Sharpened Cosine Similarity A layer implementation for PyTorch Install At your c

Brandon Rohrer 203 Nov 30, 2022
Automatic number plate recognition using tech: Yolo, OCR, Scene text detection, scene text recognation, flask, torch

Automatic Number Plate Recognition Automatic Number Plate Recognition (ANPR) is the process of reading the characters on the plate with various optica

Meftun AKARSU 52 Dec 22, 2022
A forwarding MPI implementation that can use any other MPI implementation via an MPI ABI

MPItrampoline MPI wrapper library: MPI trampoline library: MPI integration tests: MPI is the de-facto standard for inter-node communication on HPC sys

Erik Schnetter 31 Dec 22, 2022
ALBERT-pytorch-implementation - ALBERT pytorch implementation

ALBERT-pytorch-implementation developing... 모델의 개념이해를 돕기 위한 구현물로 현재 변수명을 상세히 적었고

BG Kim 3 Oct 6, 2022
Numenta Platform for Intelligent Computing is an implementation of Hierarchical Temporal Memory (HTM), a theory of intelligence based strictly on the neuroscience of the neocortex.

NuPIC Numenta Platform for Intelligent Computing The Numenta Platform for Intelligent Computing (NuPIC) is a machine intelligence platform that implem

Numenta 6.3k Dec 30, 2022
PyTorch implementation of neural style transfer algorithm

neural-style-pt This is a PyTorch implementation of the paper A Neural Algorithm of Artistic Style by Leon A. Gatys, Alexander S. Ecker, and Matthias

null 770 Jan 2, 2023
PyTorch implementation of DeepDream algorithm

neural-dream This is a PyTorch implementation of DeepDream. The code is based on neural-style-pt. Here we DeepDream a photograph of the Golden Gate Br

null 121 Nov 5, 2022
The project is an official implementation of our CVPR2019 paper "Deep High-Resolution Representation Learning for Human Pose Estimation"

Deep High-Resolution Representation Learning for Human Pose Estimation (CVPR 2019) News [2020/07/05] A very nice blog from Towards Data Science introd

Leo Xiao 3.9k Jan 5, 2023
Image-to-Image Translation with Conditional Adversarial Networks (Pix2pix) implementation in keras

pix2pix-keras Pix2pix implementation in keras. Original paper: Image-to-Image Translation with Conditional Adversarial Networks (pix2pix) Paper Author

William Falcon 141 Dec 30, 2022