Pytorch implementation of Deep Recursive Residual Network for Super Resolution (DRRN)

Overview

DRRN-pytorch

This is an unofficial implementation of "Deep Recursive Residual Network for Super Resolution (DRRN)", CVPR 2017 in Pytorch. [Paper]

You can get the official Caffe implementation here.

Usage

Training

usage: main.py [-h] [--batchSize BATCHSIZE] [--nEpochs NEPOCHS] [--lr LR]
               [--step STEP] [--cuda] [--resume RESUME]
               [--start-epoch START_EPOCH] [--clip CLIP] [--threads THREADS]
               [--momentum MOMENTUM] [--weight-decay WEIGHT_DECAY]
               [--pretrained PRETRAINED]
               
optional arguments:
  -h, --help            Show this help message and exit
  --batchSize           Training batch size
  --nEpochs             Number of epochs to train for
  --lr                  Learning rate. Default=0.1
  --step                Learning rate decay, Default: n=5 epochs
  --cuda                Use cuda?
  --resume              Path to checkpoint
  --clip                Clipping Gradients. Default=0.01
  --threads             Number of threads for data loader to use Default=1
  --momentum            Momentum, Default: 0.9
  --weight-decay        Weight decay, Default: 1e-4
  --pretrained          Path to the pretrained model, used for weight initialization (default: none)

Evaluation

usage: eval.py [-h] [--cuda] [--model MODEL] [--dataset DATASET]
               [--scale SCALE]

PyTorch DRRN Evaluation

optional arguments:
  -h, --help         show this help message and exit
  --cuda             use cuda?
  --model MODEL      model path
  --dataset DATASET  dataset name, Default: Set5

An example of training usage is shown as follows:

python eval.py --cuda

Prepare Training dataset

  • the training data is generated with Matlab Bicubic Interpolation, please refer Code for Data Generation for creating training files.

Performance

  • We provide a rough pre-trained DRRN_B1U25 model trained on 291 images with data augmentation. The model can achieve a better performance with a smart optimization strategy. For the DRRN_B1U9 implementation, you can manually modify the number of recursive blocks here.
  • The same adjustable gradient clipping's implementation as original paper.
  • No bias is used in this implementation.
  • No batch normalization is used in this implementation.
  • Performance in PSNR on Set5
Scale DRRN_B1U25 Paper DRRN_B1U25 PyTorch
x2 37.74 37.69
x3 34.03 34.02
x4 31.68 31.70
Comments
  • how does your implementation share the weight?

    how does your implementation share the weight?

    Hi, there, I don't find the any code to evident that the parameter is shared. Maybe becanse I don't I understand how to use the "weight shared function" of pytorch? Can u help me? thanks.

    class DRRN(nn.Module):
    	def __init__(self):
    		super(DRRN, self).__init__()
    		self.input = nn.Conv2d(in_channels=1, out_channels=128, kernel_size=3, stride=1, padding=1, bias=False)
    		self.conv1 = nn.Conv2d(in_channels=128, out_channels=128, kernel_size=3, stride=1, padding=1, bias=False)
    		self.conv2 = nn.Conv2d(in_channels=128, out_channels=128, kernel_size=3, stride=1, padding=1, bias=False)
    		self.output = nn.Conv2d(in_channels=128, out_channels=1, kernel_size=3, stride=1, padding=1, bias=False)
    		self.relu = nn.ReLU(inplace=True)
    
    		# weights initialization
    		for m in self.modules():
    			if isinstance(m, nn.Conv2d):
    				n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
    				m.weight.data.normal_(0, sqrt(2. / n))
    
    	def forward(self, x):
    		residual = x
    		inputs = self.input(self.relu(x))
    		out = inputs
    		for _ in range(25):
    			out = self.conv2(self.relu(self.conv1(self.relu(out))))
    			out = torch.add(out, inputs)
    
    		out = self.output(self.relu(out))
    		out = torch.add(out, residual)
    return out
    
    opened by pzz2011 1
  • 如何用自己数据集测试(How to test with my own dataset.)

    如何用自己数据集测试(How to test with my own dataset.)

    I want to be able to test with my own dataset. First, I need to convert the image to. Mat, such as a_ x2.mat ,a_ x4.mat In the project, for example, How is the file baby_ GT_ x2.mat generated?

    我希望能用自己的数据集测试,首先需要将图片转换为.mat,如a_x2.mat ,a_x4.mat 请问项目中例如baby_GT_x2.mat的文件是如何生成的?

    opened by clttyou 0
  • h5py objects cannot be pickled

    h5py objects cannot be pickled

    Hello, after I finished the H5 file on MATLAB, I ran main.py for training, and the TypeError: h5py objects cannot be pickled error appeared. What could be the reason?

    opened by qiqiing 0
  • 不能得到和论文一样的结果

    不能得到和论文一样的结果

    感谢大佬开源,我按照你的代码,没有改任何代码,跑50 epoch,发现在第50 epoch得到结果如下: Processing Set5_mat/head_GT_x2.mat Processing Set5_mat/butterfly_GT_x2.mat Processing Set5_mat/baby_GT_x2.mat Processing Set5_mat/woman_GT_x2.mat Scale= 2 Dataset= Set5 PSNR_predicted= 35.98152927120101 PSNR_bicubic= 33.69039381292539 It takes average 5.726621294021607s for processing Processing Set5_mat/woman_GT_x3.mat Processing Set5_mat/bird_GT_x3.mat Processing Set5_mat/baby_GT_x3.mat Processing Set5_mat/head_GT_x3.mat Processing Set5_mat/butterfly_GT_x3.mat Scale= 3 Dataset= Set5 PSNR_predicted= 32.590871083509164 PSNR_bicubic= 30.407692343235453 It takes average 5.687644147872925s for processing Processing Set5_mat/bird_GT_x4.mat Processing Set5_mat/woman_GT_x4.mat Processing Set5_mat/butterfly_GT_x4.mat Processing Set5_mat/head_GT_x4.mat Processing Set5_mat/baby_GT_x4.mat Scale= 4 Dataset= Set5 PSNR_predicted= 30.483599758580993 PSNR_bicubic= 28.41454827257395 It takes average 5.374003458023071s for processing

    相反的是我在第20 epoch得到了更好的结果,emmm,如果大佬有时间可以麻烦解答下么: Processing Set5_mat/head_GT_x2.mat Processing Set5_mat/butterfly_GT_x2.mat Processing Set5_mat/baby_GT_x2.mat Processing Set5_mat/woman_GT_x2.mat Scale= 2 Dataset= Set5 PSNR_predicted= 36.17091792433612 PSNR_bicubic= 33.69039381292539 It takes average 5.751824855804443s for processing Processing Set5_mat/woman_GT_x3.mat Processing Set5_mat/bird_GT_x3.mat Processing Set5_mat/baby_GT_x3.mat Processing Set5_mat/head_GT_x3.mat Processing Set5_mat/butterfly_GT_x3.mat Scale= 3 Dataset= Set5 PSNR_predicted= 32.7447910082183 PSNR_bicubic= 30.407692343235453 It takes average 5.653450155258179s for processing Processing Set5_mat/bird_GT_x4.mat Processing Set5_mat/woman_GT_x4.mat Processing Set5_mat/butterfly_GT_x4.mat Processing Set5_mat/head_GT_x4.mat Processing Set5_mat/baby_GT_x4.mat Scale= 4 Dataset= Set5 PSNR_predicted= 30.44373425939143 PSNR_bicubic= 28.41454827257395 It takes average 5.370740699768066s for processing

    opened by chaoyueziji 2
  • training problem

    training problem

    Thank you for your wonderful work! I want to train a model with my own dataset, but there are something wrong in the process. The error is described as below:

    ===> Loading datasets ===> Building model /home/luomeilu/anaconda3/envs/py2/lib/python2.7/site-packages/torch/nn/_reduction.py:49: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead. warnings.warn(warning.format(ret)) ===> Setting GPU ===> load model model/model_epoch_28.pth /home/luomeilu/anaconda3/envs/py2/lib/python2.7/site-packages/torch/serialization.py:435: SourceChangeWarning: source code of class 'torch.nn.parallel.data_parallel.DataParallel' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /home/luomeilu/anaconda3/envs/py2/lib/python2.7/site-packages/torch/serialization.py:435: SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /home/luomeilu/anaconda3/envs/py2/lib/python2.7/site-packages/torch/serialization.py:435: SourceChangeWarning: source code of class 'torch.nn.modules.activation.ReLU' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) Traceback (most recent call last): File "main.py", line 128, in main() File "main.py", line 69, in main model.load_state_dict(weights['model'].state_dict()) File "/home/luomeilu/anaconda3/envs/py2/lib/python2.7/site-packages/torch/nn/modules/module.py", line 769, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for DRRN: Missing key(s) in state_dict: "input.weight", "conv1.weight", "conv2.weight", "output.weight". Unexpected key(s) in state_dict: "module.input.weight", "module.conv1.weight", "module.conv2.weight", "module.output.weight".

    It seems that the parameters in model are miss? I can't understand the error, hoping you can give me some suggestions. Sincerely appreciate for your reply.

    opened by meroluo 1
Owner
yun_yang
yun_yang
PyTorch version of the paper 'Enhanced Deep Residual Networks for Single Image Super-Resolution' (CVPRW 2017)

About PyTorch 1.2.0 Now the master branch supports PyTorch 1.2.0 by default. Due to the serious version problem (especially torch.utils.data.dataloade

Sanghyun Son 2.1k Jan 1, 2023
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
Image Super-Resolution Using Very Deep Residual Channel Attention Networks

Image Super-Resolution Using Very Deep Residual Channel Attention Networks

kongdebug 14 Oct 14, 2022
pytorch implementation for Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network arXiv:1609.04802

PyTorch SRResNet Implementation of Paper: "Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network"(https://arxiv.org/abs

Jiu XU 436 Jan 9, 2023
Pytorch implementation of “Recursive Non-Autoregressive Graph-to-Graph Transformer for Dependency Parsing with Iterative Refinement”

Graph-to-Graph Transformers Self-attention models, such as Transformer, have been hugely successful in a wide range of natural language processing (NL

Idiap Research Institute 40 Aug 14, 2022
PyTorch implementation of 1712.06087 "Zero-Shot" Super-Resolution using Deep Internal Learning

Unofficial PyTorch implementation of "Zero-Shot" Super-Resolution using Deep Internal Learning Unofficial Implementation of 1712.06087 "Zero-Shot" Sup

Jacob Gildenblat 196 Nov 27, 2022
Official PyTorch implementation of the paper "Deep Constrained Least Squares for Blind Image Super-Resolution", CVPR 2022.

Deep Constrained Least Squares for Blind Image Super-Resolution [Paper] This is the official implementation of 'Deep Constrained Least Squares for Bli

MEGVII Research 141 Dec 30, 2022
Deep Learning: Architectures & Methods Project: Deep Learning for Audio Super-Resolution

Deep Learning: Architectures & Methods Project: Deep Learning for Audio Super-Resolution Figure: Example visualization of the method and baseline as a

Oliver Hahn 16 Dec 23, 2022
The official pytorch implemention of the CVPR paper "Temporal Modulation Network for Controllable Space-Time Video Super-Resolution".

This is the official PyTorch implementation of TMNet in the CVPR 2021 paper "Temporal Modulation Network for Controllable Space-Time VideoSuper-Resolu

Gang Xu 95 Oct 24, 2022
PyTorch code for our paper "Attention in Attention Network for Image Super-Resolution"

Under construction... Attention in Attention Network for Image Super-Resolution (A2N) This repository is an PyTorch implementation of the paper "Atten

Haoyu Chen 71 Dec 30, 2022
PyTorch code for our ECCV 2020 paper "Single Image Super-Resolution via a Holistic Attention Network"

HAN PyTorch code for our ECCV 2020 paper "Single Image Super-Resolution via a Holistic Attention Network" This repository is for HAN introduced in the

五维空间 140 Nov 23, 2022
Official PyTorch code for Mutual Affine Network for Spatially Variant Kernel Estimation in Blind Image Super-Resolution (MANet, ICCV2021)

Mutual Affine Network for Spatially Variant Kernel Estimation in Blind Image Super-Resolution (MANet, ICCV2021) This repository is the official PyTorc

Jingyun Liang 139 Dec 29, 2022
PyTorch implementation of the Pose Residual Network (PRN)

Pose Residual Network This repository contains a PyTorch implementation of the Pose Residual Network (PRN) presented in our ECCV 2018 paper: Muhammed

Salih Karagoz 289 Nov 28, 2022
Official implementation of the paper 'Efficient and Degradation-Adaptive Network for Real-World Image Super-Resolution'

DASR Paper Efficient and Degradation-Adaptive Network for Real-World Image Super-Resolution Jie Liang, Hui Zeng, and Lei Zhang. In arxiv preprint. Abs

null 81 Dec 28, 2022
A PyTorch implementation for PyramidNets (Deep Pyramidal Residual Networks)

A PyTorch implementation for PyramidNets (Deep Pyramidal Residual Networks) This repository contains a PyTorch implementation for the paper: Deep Pyra

Greg Dongyoon Han 262 Jan 3, 2023
Official implementation of Deep Burst Super-Resolution

Deep-Burst-SR Official implementation of Deep Burst Super-Resolution Publication: Deep Burst Super-Resolution. Goutam Bhat, Martin Danelljan, Luc Van

Goutam Bhat 113 Dec 19, 2022
Official implementation of Unfolded Deep Kernel Estimation for Blind Image Super-resolution.

Unfolded Deep Kernel Estimation for Blind Image Super-resolution Hongyi Zheng, Hongwei Yong, Lei Zhang, "Unfolded Deep Kernel Estimation for Blind Ima

Z80 15 Dec 26, 2022
Super-Fast-Adversarial-Training - A PyTorch Implementation code for developing super fast adversarial training

Super-Fast-Adversarial-Training This is a PyTorch Implementation code for develo

LBK 26 Dec 2, 2022
PyTorch implementation of Graph Convolutional Networks in Feature Space for Image Deblurring and Super-resolution, IJCNN 2021.

GCResNet PyTorch implementation of Graph Convolutional Networks in Feature Space for Image Deblurring and Super-resolution, IJCNN 2021. The code will

null 11 May 19, 2022