GithubHelp home page GithubHelp logo

121644048 / classsr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xpixelgroup/classsr

0.0 0.0 0.0 1.45 MB

(CVPR2021) ClassSR: A General Framework to Accelerate Super-Resolution Networks by Data Characteristic

Python 95.26% MATLAB 4.74%

classsr's Introduction

ClassSR

(CVPR2021) ClassSR: A General Framework to Accelerate Super-Resolution Networks by Data Characteristic.

Paper

Authors: Xiangtao Kong, Hengyuan Zhao, Yu Qiao, Chao Dong

Demo Image

Abstract

We aim at accelerating super-resolution (SR) networks on large images (2K-8K). The large images are usually decomposed into small sub-images in practical usages. Based on this processing, we found that different image regions have different restoration difficulties and can be processed by networks with different capacities. Intuitively, smooth areas are easier to super-solve than complex textures. To utilize this property, we can adopt appropriate SR networks to process different sub-images after the decomposition. On this basis, we propose a new solution pipeline -- ClassSR that combines classification and SR in a unified framework. In particular, it first uses a Class-Module to classify the sub-images into different classes according to restoration difficulties, then applies an SR-Module to perform SR for different classes. The Class-Module is a conventional classification network, while the SR-Module is a network container that consists of the to-be-accelerated SR network and its simplified versions. We further introduce a new classification method with two losses -- Class-Loss and Average-Loss to produce the classification results. After joint training, a majority of sub-images will pass through smaller networks, thus the computational cost can be significantly reduced. Experiments show that our ClassSR can help most existing methods (e.g., FSRCNN, CARN, SRResNet, RCAN) save up to 50% FLOPs on DIV8K datasets. This general framework can also be applied in other low-level vision tasks.

Dependencies

Codes

  • Our codes version based on BasicSR.

How to test a single branch

  1. Clone this github repo.
git clone https://github.com/Xiangtaokong/ClassSR.git
cd ClassSR
  1. Download the testing datasets (DIV2K_valid).

  2. Download the divide_val.log and move it to .codes/data_scripts/.

  3. Generate simple, medium, hard (class1, class2, class3) validation data.

cd codes/data_scripts
python extract_subimages_test.py
python divide_subimages_test.py
  1. Download pretrained models and move them to ./experiments/pretrained_models/ folder.

  2. Run testing for a single branch.

cd codes
python test.py -opt options/test/test_FSRCNN.yml
python test.py -opt options/test/test_CARN.yml
python test.py -opt options/test/test_SRResNet.yml
python test.py -opt options/test/test_RCAN.yml
  1. The output results will be sorted in ./results.

How to test ClassSR

  1. Clone this github repo.
git clone https://github.com/Xiangtaokong/ClassSR.git
cd ClassSR
  1. Download the testing datasets (Test2K, 4K, 8K) Google Drive or Baidu Drive (Password: 7dw1) .

  2. You can also download the source data DIV8K. Test8K contains the images (index 1401-1500) from DIV8K. Test2K/4K contain the images (index 1201-1300/1301-1400) from DIV8K which are downsampled to 2K and 4K resolution. (In this way, you need register for the competition (Ntire 2020 was held on 2020, but we can register now), then you can download DIV8K dataset.)

  3. Download pretrained models and move them to ./experiments/pretrained_models/ folder.

  4. Run testing for ClassSR.

cd codes
python test_ClassSR.py -opt options/test/test_ClassSR_FSRCNN.yml
python test_ClassSR.py -opt options/test/test_ClassSR_CARN.yml
python test_ClassSR.py -opt options/test/test_ClassSR_SRResNet.yml
python test_ClassSR.py -opt options/test/test_ClassSR_RCAN.yml
  1. The output results will be sorted in ./results.

How to train a single branch

  1. Clone this github repo.
git clone https://github.com/Xiangtaokong/ClassSR.git
cd ClassSR
  1. Download the training datasets(DIV2K) and validation dataset(Set5).

  2. Download the divide_train.log and move it to .codes/data_scripts/.

  3. Generate simple, medium, hard (class1, class2, class3) training data.

cd codes/data_scripts
python data_augmentation.py
python generate_mod_LR_bic.py
python extract_subimages_train.py
python divide_subimages_train.py
  1. Run training for a single branch (default branch1, the simplest branch).
cd codes
python train.py -opt options/train/train_FSRCNN.yml
python train.py -opt options/train/train_CARN.yml
python train.py -opt options/train/train_SRResNet.yml
python train.py -opt options/train/train_RCAN.yml
  1. The experiments will be sorted in ./experiments.

How to train ClassSR

  1. Clone this github repo.
git clone https://github.com/Xiangtaokong/ClassSR.git
cd ClassSR
  1. Download the training datasets (DIV2K) and validation dataset(DIV2K_valid, index 801-810).

  2. Generate training data (the all data(1.59M) in paper).

cd codes/data_scripts
python data_augmentation.py
python generate_mod_LR_bic.py
python extract_subimages_train.py
  1. Download pretrained models(pretrained branches) and move them to ./experiments/pretrained_models/ folder.

  2. Run training for ClassSR.

cd codes
python train_ClassSR.py -opt options/train/train_ClassSR_FSRCNN.yml
python train_ClassSR.py -opt options/train/train_ClassSR_CARN.yml
python train_ClassSR.py -opt options/train/train_ClassSR_SRResNet.yml
python train_ClassSR.py -opt options/train/train_ClassSR_RCAN.yml
  1. The experiments will be sorted in ./experiments.

How to generate demo images

Generate demo images like this one:

Demo Image

Change the 'add_mask: False' to True in test_ClassSR_xxx.yml and run testing for ClassSR.

Citation

@InProceedings{Kong_2021_CVPR,
    author    = {Kong, Xiangtao and Zhao, Hengyuan and Qiao, Yu and Dong, Chao},
    title     = {ClassSR: A General Framework to Accelerate Super-Resolution Networks by Data Characteristic},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2021},
    pages     = {12016-12025}
}

Contact

Email: [email protected]

classsr's People

Contributors

xiangtaokong avatar zhaohengyuan1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.