Torch implementation of "Enhanced Deep Residual Networks for Single Image Super-Resolution"

Overview

NTIRE2017 Super-resolution Challenge: SNU_CVLab

Introduction

This is our project repository for CVPR 2017 Workshop (2nd NTIRE).

We, Team SNU_CVLab, (Bee Lim, Sanghyun Son, Heewon Kim, Seungjun Nah, and Kyoung Mu Lee of Computer Vision Lab, Seoul National University) are winners of NTIRE2017 Challenge on Single Image Super-Resolution.

Our paper was published in CVPR 2017 workshop (2nd NTIRE), and won the Best Paper Award of the workshop challenge track.

Please refer to our paper for details.

If you find our work useful in your research or publication, please cite our work:

[1] Bee Lim, Sanghyun Son, Heewon Kim, Seungjun Nah, and Kyoung Mu Lee, "Enhanced Deep Residual Networks for Single Image Super-Resolution," 2nd NTIRE: New Trends in Image Restoration and Enhancement workshop and challenge on image super-resolution in conjunction with CVPR 2017. [PDF] [arXiv] [Slide]

@InProceedings{Lim_2017_CVPR_Workshops,
  author = {Lim, Bee and Son, Sanghyun and Kim, Heewon and Nah, Seungjun and Lee, Kyoung Mu},
  title = {Enhanced Deep Residual Networks for Single Image Super-Resolution},
  booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR) Workshops},
  month = {July},
  year = {2017}
}

In this repository, we provide

  • Our model architecture description (EDSR, MDSR)
  • NTIRE2017 Super-resolution Challenge Results
  • Demo & Training code
  • Trained models (EDSR, MDSR)
  • Datasets we used (DIV2K, Flickr2K)
  • Super-resolution examples

The code is based on Facebook's Torch implementation of ResNet (facebook/fb.resnet.torch).

We also provide PyTorch version of EDSR and MDSR. (Until now, only some models are available.)

Model Architecture

EDSR (Single-scale model. We provide scale x2, x3, x4 models).

EDSR

MDSR (Multi-scale model. It can handle x2, x3, x4 super-resolution in a single model).

MDSR

Note that the MDSR architecture for the challenge and for the paper[1] is slightly different. During the challenge, MDSR had variation between two challenge tracks. While we had scale-specific feature extraction modules for track 2:unknown downscaling, we didn't use the scale-specific modules for track 1:bicubic downscaling.

We later unified the MDSR model in our paper[1] by including scale-specific modules for both cases. From now on, unless specified as "challenge", we describe the models described in the paper.

NTIRE2017 Super-resolution Challenge Results

We proposed 2 methods and they won the 1st (EDSR) and 2nd (MDSR) place.

Challenge_result

We have also compared the super-resolution performance of our models with previous state-of-the-art methods.

Paper_result

About our code

Dependencies

  • Torch7
  • cuDNN
  • nccl (Optional, for faster GPU communication)

Our code is tested under Ubuntu 14.04 and 16.04 environment with Titan X GPUs (12GB VRAM).

Code

Clone this repository into any place you want. You may follow the example below.

makeReposit = [/the/directory/as/you/wish]
mkdir -p $makeReposit/; cd $makeReposit/
git clone https://github.com/LimBee/NTIRE2017.git

Quick Start (Demo)

You can test our super-resolution algorithm with your own images.

We assume the images are downsampled by bicubic interpolation.

Model Scale File Name Self Esemble # ResBlocks # Filters # Parameters
EDSR baseline x2 baseline_x2.t7 X 16 64 1.5M
EDSR baseline x3 baseline_x3.t7 X 16 64 1.5M
EDSR baseline x4 baseline_x4.t7 X 16 64 1.5M
MDSR baseline Multi baseline_multiscale.t7 X 16 64 3.2M
EDSR x2 EDSR_x2.t7 X 32 256 43M
EDSR x3 EDSR_x3.t7 X 32 256 43M
EDSR x4 EDSR_x4.t7 X 32 256 43M
MDSR Multi MDSR.t7 X 80 64 8.0M
EDSR+ x2 EDSR_x2.t7 O 32 256 43M
EDSR+ x3 EDSR_x3.t7 O 32 256 43M
EDSR+ x4 EDSR_x4.t7 O 32 256 43M
MDSR+ Multi MDSR.t7 O 80 64 8.0M

  1. Download our models

    cd $makeReposit/NTIRE2017/demo/model/
    
    # Our models for the paper[1]
    wget https://cv.snu.ac.kr/research/EDSR/model_paper.tar

    Or, use the link: model_paper.tar

    (If you would like to run the models we used during the challenge, please contact us.)

    After downloading the .tar files, make sure that the model files are placed in proper locations. For example,

    $makeReposit/NTIRE2017/demo/model/bicubic_x2.t7
    $makeReposit/NTIRE2017/demo/model/bicubic_x3.t7
    ...
  2. Place your low-resolution test images at

    $makeReposit/NTIRE2017/demo/img_input/

    The demo code will read .jpg, .jpeg, .png format images.

  3. Run test.lua

    You can run different models and scales by changing input arguments.

    # To run for scale 2, 3, or 4, set -scale as 2, 3, or 4
    # To run EDSR+ and MDSR+, you need to set -selfEnsemble as true
    
    cd $makeReposit/NTIRE2017/demo
    
    # Test EDSR (scale 2)
    th test.lua -model EDSR_x2 -selfEnsemble false
    
    # Test EDSR+ (scale 2)
    th test.lua -model EDSR_x2 -selfEnsemble true
    
    # Test MDSR (scale 2)
    th test.lua -model MDSR -scale 2 -selfEnsemble false
    
    # Test MDSR+ (scale 2)
    th test.lua -model MDSR -scale 2 -selfEnsemble true

    (Note: To run the MDSR, model name should include multiscale or MDSR. e.g. multiscale_blahblahblah.t7)

    The result images will be located at

    $makeReposit/NTIRE2017/demo/img_output/
    • Here are some optional argument examples you can adjust. Please refer to the following explanation.
    # You can test our model with multiple GPU. (n = 1, 2, 4)
    -nGPU       [n]
    
    # You must specify this directory. Default is /var/tmp/dataset
    -dataDir    [$makeData]
    -dataset    [DIV2K | myData]
    -save       [Folder name]
    
    # Please see our paper[1] if you want to know about self-ensemble.
    -selfEnsemble   [true | false]
    
    # Please reduce the chopSize when you see 'out of memory'.
    # The optimal size of S can be vary depend on your maximum GPU memory.
    -chopSize   [S]   
  4. (Optional) Evaluate PSNR and SSIM if you have ground-truth HR images

    Place the GT images at

    $makeReposit/NTIRE2017/demo/img_target

    Evaluation is done by running the MATLAB script.

    matlab -nodisplay <evaluation.m

    If you don't want to calculate SSIM, please modify evaluation.m file as below. (Calculating SSIM of large image is very slow for 3 channel images.)

    line 6:     psnrOnly = false; -> psnrOnly = true;
    

You can reproduce our final results by running makeFinal.sh in NTIRE2017/demo directory. Please uncomment the command you want to execute in the file.

sh makeFinal.sh

Dataset

If you want to train or evaluate our models with DIV2K or Flickr2K dataset, please download the dataset from here. Place the tar file to the location you want. (We recommend /var/tmp/dataset/) If the dataset is located otherwise, you have to change the optional argument -dataset for training and test.

  • DIV2K from NTIRE2017

    makeData = /var/tmp/dataset/ # We recommend this path, but you can freely change it.
    mkdir -p $makeData/; cd $makedata/
    tar -xvf DIV2K.tar

    You should have the following directory structure:

    /var/tmp/dataset/DIV2K/DIV2K_train_HR/0???.png
    /var/tmp/dataset/DIV2K/DIV2K_train_LR_bicubic/X?/0???.png
    /var/tmp/dataset/DIV2K/DIV2K_train_LR_unknown/X?/0???.png

  • Flickr2K dataset collected by ourselves using Flickr API

    makeData = /var/tmp/dataset/
    mkdir -p $makeData/; cd $makedata/
    wget https://cv.snu.ac.kr/research/EDSR/Flickr2K.tar
    tar -xvf Flickr2K.tar

    You should have the following directory structure:

    /var/tmp/dataset/Flickr2K/Flickr2K_HR/00????.png
    /var/tmp/dataset/Flickr2K/Flickr2K_train_LR_bicubic/X?/00????x?.png
    /var/tmp/dataset/Flickr2K/Flickr2K_train_LR_unknown/X?/00????x?.png

    We also provide the code we used for collecting the Flickr2K images at

    $makeReposit/NTIRE2017/code/tools/Flickr2K/

    Use your own flickr API keys to use the script.

    During the challenge, we additionally generated training data by learning simple downsampler networks from DIV2K dataset track 2.
    You can download the downsampler models from here.

To make data loading faster, you can convert the dataset into binary .t7 files

  • Convert DIV2K dataset from .png to into .t7 files
    cd $makeReposit/NTIRE2017/code/tools
    
    # Choose one among below
    
    # This command generates multiple t7 files for
    # each image in DIV2K_train_HR folder (Requires ~2GB RAM for training)
    th png_to_t7.lua -apath $makeData -dataset DIV2K -split true
    
    # This command generates a single t7 file that contains
    # every image in DIV2K_train_HR folder (Requires ~16GB RAM for training)
    th png_to_t7.lua -apath $makeData -dataset DIV2K -split false
  • Convert Flickr2K dataset into .t7 files
    cd $makeReposit/NTIRE2017/code/tools
    
    # This command generates multiple t7 files for
    # each image in Flickr2K_HR folder
    th png_to_t7.lua -apath $makeData -dataset Flickr2K -split true

You can also use .png files too. Please see below Training section for the details.

Training

  1. To train our baseline model, please run the following command:

    th main.lua         # This model is not our final model!
    • Here are some optional arguments you can adjust. If you have any problem, please refer following lines. You can check out details in NTIRE2017/code/opts.lua.
      # You can train the model with multiple GPU. (Not multi-scale model.)
      -nGPU       [n]
      
      # Number of threads for data loading.
      -nThreads   [n]   
      
      # Please specify this directory. Default is /var/tmp/dataset
      -datadir    [$makeData]  
      
      # You can make an experiment folder with the name you want.
      -save       [Folder name]
      
      # You can resume your experiment from the last checkpoint.
      # Please do not set -save and -load at the same time.
      -load       [Folder name]     
      
      # png < t7 < t7pack - requires larger memory
      # png > t7 > t7pack - requires faster CPU & Storage
      -datatype   [png | t7 | t7pack]     
      
      # Please increase the splitBatch when you see 'out of memory' during training.
      # S should be the power of 2. (1, 2, 4, ...)
      -splitBatch [S]
      
      # Please reduce the chopSize when you see 'out of memory' during test.
      # The optimal size of S can be vary depend on your maximum GPU memory.
      -chopSize   [S]
  2. To train our EDSR and MDSR, please use the training.sh in NTIRE2017/code directory. You have to uncomment the line you want to execute.

    cd $makeReposit/NTIRE2017/code
    sh training.sh

    Some model may require pre-trained bicubic scale 2 or bicubic multiscale model. Here, we assume that you already downloaded bicubic_x2.t7 and bicubic_multiscale.t7 in the NTIRE2017/demo/model directory. Otherwise, you can create them yourself. It is also possible to start the traning from scratch by removing -preTrained option in training.sh.


Results

result_1

result_2

result_3

result_4

result_5

result_6

result_7

result_8

result_9

result_10

result_11

result_12

result_13

result_14

result_15

result_16

result_17

result_18

result_19

result_20

NTIRE2017 SR Challenge: Unknown Down-sampling Track

unknown_1

unknown_2

Owner
Bee Lim
Bee Lim
FFCV: Fast Forward Computer Vision (and other ML workloads!)

Fast Forward Computer Vision: train models at a fraction of the cost with accele

FFCV 2.3k Jan 03, 2023
Library of various Few-Shot Learning frameworks for text classification

FewShotText This repository contains code for the paper A Neural Few-Shot Text Classification Reality Check Environment setup # Create environment pyt

Thomas Dopierre 47 Jan 03, 2023
This folder contains the python code of UR5E's advanced forward kinematics model.

This folder contains the python code of UR5E's advanced forward kinematics model. By entering the angle of the joint of UR5e, the detailed coordinates of up to 48 points around the robot arm can be c

Qiang Wang 4 Sep 17, 2022
Official PyTorch Implementation of Mask-aware IoU and maYOLACT Detector [BMVC2021]

The official implementation of Mask-aware IoU and maYOLACT detector. Our implementation is based on mmdetection. Mask-aware IoU for Anchor Assignment

Kemal Oksuz 46 Sep 29, 2022
Cupytorch - A small framework mimics PyTorch using CuPy or NumPy

CuPyTorch CuPyTorch是一个小型PyTorch,名字来源于: 不同于已有的几个使用NumPy实现PyTorch的开源项目,本项目通过CuPy支持

Xingkai Yu 23 Aug 17, 2022
[NeurIPS 2021 Spotlight] Code for Learning to Compose Visual Relations

Learning to Compose Visual Relations This is the pytorch codebase for the NeurIPS 2021 Spotlight paper Learning to Compose Visual Relations. Demo Imag

Nan Liu 88 Jan 04, 2023
General neural ODE and DAE modules for power system dynamic modeling.

Py_PSNODE General neural ODE and DAE modules for power system dynamic modeling. The PyTorch-based ODE solver is developed based on torchdiffeq. Sample

14 Dec 31, 2022
Cleaned up code for DSTC 10: SIMMC 2.0 track: subtask 2: multimodal coreference resolution

UNITER-Based Situated Coreference Resolution with Rich Multimodal Input: arXiv MMCoref_cleaned Code for the MMCoref task of the SIMMC 2.0 dataset. Pre

Yichen (William) Huang 2 Dec 05, 2022
Deep learning model, heat map, data prepo

deep learning model, heat map, data prepo

Pamela Dekas 1 Jan 14, 2022
Intelligent Video Analytics toolkit based on different inference backends.

English | 中文 OpenIVA OpenIVA is an end-to-end intelligent video analytics development toolkit based on different inference backends, designed to help

Quantum Liu 15 Oct 27, 2022
[ICCV 2021] Official Pytorch implementation for Discriminative Region-based Multi-Label Zero-Shot Learning SOTA results on NUS-WIDE and OpenImages

Discriminative Region-based Multi-Label Zero-Shot Learning (ICCV 2021) [arXiv][Project page coming soon] Sanath Narayan*, Akshita Gupta*, Salman Kh

Akshita Gupta 54 Nov 21, 2022
TensorFlow implementation of "Learning from Simulated and Unsupervised Images through Adversarial Training"

Simulated+Unsupervised (S+U) Learning in TensorFlow TensorFlow implementation of Learning from Simulated and Unsupervised Images through Adversarial T

Taehoon Kim 569 Dec 29, 2022
Measures input lag without dedicated hardware, performing motion detection on recorded or live video

What is InputLagTimer? This tool can measure input lag by analyzing a video where both the game controller and the game screen can be seen on a webcam

Bruno Gonzalez 4 Aug 18, 2022
Code for the paper "Unsupervised Contrastive Learning of Sound Event Representations", ICASSP 2021.

Unsupervised Contrastive Learning of Sound Event Representations This repository contains the code for the following paper. If you use this code or pa

Eduardo Fonseca 81 Dec 22, 2022
PyTorch implementation of TSception V2 using DEAP dataset

TSception This is the PyTorch implementation of TSception V2 using DEAP dataset in our paper: Yi Ding, Neethu Robinson, Su Zhang, Qiuhao Zeng, Cuntai

Yi Ding 27 Dec 15, 2022
Implementation of Research Paper "Learning to Enhance Low-Light Image via Zero-Reference Deep Curve Estimation"

Zero-DCE and Zero-DCE++(Lite architechture for Mobile and edge Devices) Papers Abstract The paper presents a novel method, Zero-Reference Deep Curve E

Tauhid Khan 15 Dec 10, 2022
Scene-Text-Detection-and-Recognition (Pytorch)

Scene-Text-Detection-and-Recognition (Pytorch) Competition URL: https://tbrain.t

Gi-Luen Huang 9 Jan 02, 2023
Interactive Terraform visualization. State and configuration explorer.

Rover - Terraform Visualizer Rover is a Terraform visualizer. In order to do this, Rover: generates a plan file and parses the configuration in the ro

Tu Nguyen 2.3k Jan 07, 2023
ObjectDrawer-ToolBox: a graphical image annotation tool to generate ground plane masks for a 3D object reconstruction system

ObjectDrawer-ToolBox is a graphical image annotation tool to generate ground plane masks for a 3D object reconstruction system, Object Drawer.

77 Jan 05, 2023
BraTs-VNet - BraTS(Brain Tumour Segmentation) using V-Net

BraTS(Brain Tumour Segmentation) using V-Net This project is an approach to dete

Rituraj Dutta 7 Nov 27, 2022