Image Super-Resolution Using Very Deep Residual Channel Attention Networks

Overview

论文名称:Image Super-Resolution Using Very Deep Residual Channel Attention Networks

目录

1. 简介
2. 数据集和复现精度
3. 开始使用
4. 代码结构与详细说明
5. 复现模型超分效果
5. 复现模型相关信息

1. 简介

本项目复现的论文是Yulun Zhang, Kunpeng Li, Kai Li, Lichen Wang, Bineng Zhong, and Yun Fu, 发表在ECCV 2018上的论文。 作者提出了一个深度残差通道注意力网络(RCAN)。特别地,作者设计了一个残差中的残差(RIR)结构来构造深层网络,每个 RIR 结构由数个残差组(RG)以及长跳跃连接(LSC)组成,每个 RG 则包含一些残差块和短跳跃连接(SSC)。RIR 结构允许丰富的低频信息通过多个跳跃连接直接进行传播,使主网络专注于学习高频信息。此外,我们还提出了一种通道注意力机制(CA),通过考虑通道之间的相互依赖性来自适应地重新调整特征。

论文: 《Image Super-Resolution Using Very Deep Residual Channel Attention Networks》

参考repo: RCAN

在此非常感谢yulunzhang、MaFuyan、joaoherrera等人贡献的RCAN,提高了本项目的复现效率。

aistudio体验教程: 使用PaddleGAN复现RCAN

2. 数据集和复现精度

本项目所用到的训练集以及测试集包括相应的下载地址如下:

Name 数据集 数据描述 下载
2K Resolution DIV2K proposed in NTIRE17 (800 train and 100 validation) official website
Classical SR Testing Set5 Set5 test dataset Google Drive / Baidu Drive
Classical SR Testing Set14 Set14 test dataset Google Drive / Baidu Drive

数据集DIV2K, Set5 和 Set14 的组成形式如下:

  PaddleGAN
    ├── data
        ├── DIV2K
              ├── DIV2K_train_HR
              ├── DIV2K_train_LR_bicubic
              |    ├──X2
              |    ├──X3
              |    └──X4
              ├── DIV2K_valid_HR
              ├── DIV2K_valid_LR_bicubic
        ├── Set5
              ├── GTmod12
              ├── LRbicx2
              ├── LRbicx3
              ├── LRbicx4
              └── original
        ├── Set14
              ├── GTmod12
              ├── LRbicx2
              ├── LRbicx3
              ├── LRbicx4
              └── original
            ...

论文中模型(torch框架下训练)在Set14与Set5精度与使用paddle复现模型的精度对比:

框架 Set14
paddle 29.02 / 0.7910
torch 28.98 / 0.7910

Paddle模型(.pdparams)下载

模型 数据集 下载地址 提取码
rcan_x4 DIV2K rcan_x4 1ry9

3. 开始使用

3.1 准备环境

  • 硬件: Tesla V100 * 1
  • 框架:
    • PaddlePaddle >= 2.1.0
    • tqdm
    • PyYAML>=5.1
    • scikit-image>=0.14.0
    • scipy>=1.1.0
    • opencv-python
    • imageio==2.9.0
    • imageio-ffmpeg
    • librosa
    • numba==0.53.1
    • natsort
    • munch
    • easydict

将本项目git clone之后进入项目,使用pip install -r requirements.txt安装依赖即可。

3.2 快速开始

第一步:克隆本项目

# clone this repo
git clone https://github.com/kongdebug/RCAN-Paddle.git
cd RCAN-Paddle

第二步:安装依赖项

pip install -r requirements.txt

第三步:开始训练

单卡训练:

python -u tools/main.py --config-file configs/rcan_x4_div2k.yaml

由于本项目没有使用多卡训练,故不提供相关代码。 如使您想使用自己的数据集以及测试集,需要在配置文件中修改数据集为您自己的数据集。

如果训练断掉,想接着训练:

python -u tools/main.py --config-file configs/rcan_x4_div2k.yaml --resume ${PATH_OF_CHECKPOINT}

第四步:测试

  • 输出预测图像
    • 可以通过第二部分拿到paddle复现的模型,放入一个文件夹中,运行如下程序,得到模型的测试结果
    • Fig/visual文件夹中有预测结果,可直接用于精度评价
python -u tools/main.py --config-file configs/rcan_x4_div2k.yaml --evaluate-only --load ${PATH_OF_WEIGHT}
  • 对预测图像精度评价
    • 运行以上代码后,在output_dir文件夹中得到模型得预测结果,然后运行如下代码进行精度评定。注:--gt_dir与 output_dir两个参数得设置需要对应自己的实际路径。
python  tools/cal_psnr_ssim.py  --gt_dir data/Set14/GTmod12 --output_dir output_dir/rcan_x4_div2k*/visual_test

4. 代码结构与详细说明

4.1 代码结构

├─applications                          
├─benchmark                        
├─deploy                         
├─configs                          
├─data                        
├─output_dir                         
├─ppgan       
├─tools
├─test_tipc
├─Figs
│  README_cn.md                     
│  requirements.txt                      
│  setup.py                                         

4.2 结构说明

本项目基于PaddleGAN开发。configs文件夹中的rcan_x4_div2k.yaml是训练的配置文件,格式沿袭PaddleGAN中的SISR任务,参数设置与论文一致。data文件夹存放训练数据以及 测试数据。output_dir文件夹存放运行过程中输出的文件,一开始为空。test_tipc是用于导出模型预测,以及 TIPC测试的文件夹。

4.3 导出模型部署

  • 训练结束后得到rcan_checkpoint.pdparams文件,需要进行导出inference的步骤。
python3.7 tools/export_model.py -c configs/rcan_x4_div2k.yaml --inputs_size="-1,3,-1,-1" --load output_dir/rcan_checkpoint.pdparams --output_dir ./test_tipc/output/rcan_x4
  • 得到以上模型文件之后,基于PaddleInference对待预测推理的测试数据进行预测。
    • 将上一步导出的inference文件(.pdmodel、.pdiparams以及.pdiparams.info )均放入test_tipc/output/rcan_x4文件夹,注:文件名称均为basesrmodel_generator
    • 运行以下命令,在test_tipc/output/文件夹中得到预测结果
python3.7 tools/inference.py --model_type rcan --seed 123 -c configs/rcan_x4_div2k.yaml --output_path test_tipc/output/ --device=gpu --model_path=./test_tipc/output/rcan_x4/basesrmodel_generator

4.5 TIPC测试支持

test_tipc文件夹下文结构

test_tipc/
├── configs/  # 配置文件目录
    ├── rcan    
        ├── train_infer_python.txt      # 测试Linux上python训练预测(基础训练预测)的配置文件
        ├── train_infer_python_resume.txt      # 加载模型的(基础训练预测)的配置文件
├── output/   # 预测结果
├── common_func.sh    # 基础功能程序
├── prepare.sh                        # 需要的数据和模型下载
├── test_train_inference_python.sh    # 测试python训练预测的主程序
├── readme.md                # TIPC基础链接测试需要安装的依赖说明

注意: 本项目仅提供TIPC基础测试链条中模式lite_train_lite_infer的代码与文档。运行之前先使用vim查看.sh文件的filemode,需要为“filemode=unix"格式。

如果没有准备训练数据,可以运行prepare.sh下载训练数据DIV2K,然后对其解压,调整文件组织如第二部分所示; 如果已经准备好数据,运行如下命令完成TIPC基础测试:

  • 从头开始:
 bash test_tipc/test_train_inference_python.sh ./test_tipc/configs/rcan/train_infer_python.txt 'lite_train_lite_infer'

这里需要注意,这里测试训练时所用的配置文件为configs文件夹下专门为从头开始的lite_train_lite_infer模式设置 的rcan_x4_div2k_tipc.yaml文件,没有加载训练好的模型而是从头训练,所以loss会很高。运行得到的结果在output 文件夹中,项目中该文件夹已放入先前运行得到的日志文件。

  • 加载已训练模型:
    • 将下载的rcan_checkpoint.pdparams模型文件,放入output_dir文件夹下,并改名为iter_238000_checkpoint.pdparams
    • 这里测试需要用的configs文件夹下的rcan_x4_div2k.yaml文件以及train_infer_python_resume.txt文件
    • 运行以下命令:
bash test_tipc/test_train_inference_python.sh ./test_tipc/configs/rcan/train_infer_python_resume.txt 'lite_train_lite_infer'

按照”加载已训练模型“的命令运行之后,最后会得到inference预测的结果图以及精度评价,可以看到psnr与ssim均达标。

5.复现模型超分效果

低分辨率 超分重建后 高分辨率

6.复现模型相关信息

相关信息:

信息 描述
作者 不想科研的Key.L
日期 2021年11月
框架版本 PaddlePaddle==2.2.0
应用场景 图像超分
硬件支持 GPU、CPU
在线体验 notebook
Owner
kongdebug
kongdebug
Code for Paper: Self-supervised Learning of Motion Capture

Self-supervised Learning of Motion Capture This is code for the paper: Hsiao-Yu Fish Tung, Hsiao-Wei Tung, Ersin Yumer, Katerina Fragkiadaki, Self-sup

Hsiao-Yu Fish Tung 87 Jul 25, 2022
Weakly Supervised 3D Object Detection from Point Cloud with Only Image Level Annotation

SCCKTIM Weakly Supervised 3D Object Detection from Point Cloud with Only Image-Level Annotation Our code will be available soon. The class knowledge t

1 Nov 12, 2021
A library for preparing, training, and evaluating scalable deep learning hybrid recommender systems using PyTorch.

collie Collie is a library for preparing, training, and evaluating implicit deep learning hybrid recommender systems, named after the Border Collie do

ShopRunner 96 Dec 29, 2022
Fast EMD for Python: a wrapper for Pele and Werman's C++ implementation of the Earth Mover's Distance metric

PyEMD: Fast EMD for Python PyEMD is a Python wrapper for Ofir Pele and Michael Werman's implementation of the Earth Mover's Distance that allows it to

William Mayner 433 Dec 31, 2022
Transport Mode detection - can detect the mode of transport with the help of features such as acceeration,jerk etc

title emoji colorFrom colorTo sdk app_file pinned Transport_Mode_Detector 🚀 purple yellow gradio app.py false Configuration title: string Display tit

Nishant Rajadhyaksha 3 Jan 16, 2022
This is a collection of all challenges in HKCERT CTF 2021

香港網絡保安新生代奪旗挑戰賽 2021 (HKCERT CTF 2021) This is a collection of all challenges (and writeups) in HKCERT CTF 2021 Challenges ID Chinese name Name Score S

10 Jan 27, 2022
An implementation of Equivariant e2 convolutional kernals into a convolutional self attention network, applied to radio astronomy data.

EquivariantSelfAttention An implementation of Equivariant e2 convolutional kernals into a convolutional self attention network, applied to radio astro

2 Nov 09, 2021
Framework for estimating the structures and parameters of Bayesian networks (DAGs) at per-sample resolution

Sample-specific Bayesian Networks A framework for estimating the structures and parameters of Bayesian networks (DAGs) at per-sample or per-patient re

Caleb Ellington 1 Sep 23, 2022
Official code repository for the publication "Latent Equilibrium: A unified learning theory for arbitrarily fast computation with arbitrarily slow neurons"

Latent Equilibrium: A unified learning theory for arbitrarily fast computation with arbitrarily slow neurons This repository contains the code to repr

Computational Neuroscience, University of Bern 3 Aug 04, 2022
DeepOBS: A Deep Learning Optimizer Benchmark Suite

DeepOBS - A Deep Learning Optimizer Benchmark Suite DeepOBS is a benchmarking suite that drastically simplifies, automates and improves the evaluation

Aaron Bahde 7 May 12, 2020
The official implementation of our CVPR 2021 paper - Hybrid Rotation Averaging: A Fast and Robust Rotation Averaging Approach

Graph Optimizer This repo contains the official implementation of our CVPR 2021 paper - Hybrid Rotation Averaging: A Fast and Robust Rotation Averagin

Chenyu 109 Dec 23, 2022
Implementation of "StrengthNet: Deep Learning-based Emotion Strength Assessment for Emotional Speech Synthesis"

StrengthNet Implementation of "StrengthNet: Deep Learning-based Emotion Strength Assessment for Emotional Speech Synthesis" https://arxiv.org/abs/2110

RuiLiu 65 Dec 20, 2022
Anchor-free Oriented Proposal Generator for Object Detection

Anchor-free Oriented Proposal Generator for Object Detection Gong Cheng, Jiabao Wang, Ke Li, Xingxing Xie, Chunbo Lang, Yanqing Yao, Junwei Han, Intro

jbwang1997 56 Nov 15, 2022
Code for "Multi-Time Attention Networks for Irregularly Sampled Time Series", ICLR 2021.

Multi-Time Attention Networks (mTANs) This repository contains the PyTorch implementation for the paper Multi-Time Attention Networks for Irregularly

The Laboratory for Robust and Efficient Machine Learning 68 Dec 17, 2022
Evaluation framework for testing segmentation networks in PyTorch

Evaluation framework for testing segmentation networks in PyTorch. What segmentation network to choose for next Kaggle competition? This benchmark knows the answer!

Eugene Khvedchenya 37 Apr 27, 2022
Code for CVPR2021 paper "Robust Reflection Removal with Reflection-free Flash-only Cues"

Robust Reflection Removal with Reflection-free Flash-only Cues (RFC) Paper | To be released: Project Page | Video | Data Tensorflow implementation for

Chenyang LEI 162 Jan 05, 2023
Facial expression detector

A tensorflow convolutional neural network model to detect facial expressions.

Carlos Tardón Rubio 5 Apr 20, 2022
Repository providing a wide range of self-supervised pretrained models for computer vision tasks.

Hierarchical Pretraining: Research Repository This is a research repository for reproducing the results from the project "Self-supervised pretraining

Colorado Reed 53 Nov 09, 2022
This is the official PyTorch implementation for "Mesa: A Memory-saving Training Framework for Transformers".

Mesa: A Memory-saving Training Framework for Transformers This is the official PyTorch implementation for Mesa: A Memory-saving Training Framework for

Zhuang AI Group 105 Dec 06, 2022
UltraPose: Synthesizing Dense Pose with 1 Billion Points by Human-body Decoupling 3D Model

UltraPose: Synthesizing Dense Pose with 1 Billion Points by Human-body Decoupling 3D Model Official repository for the ICCV 2021 paper: UltraPose: Syn

MomoAILab 92 Dec 21, 2022