zhengchen1999 / CAT

PyTorch code for our NeurIPS 2022 paper "Cross Aggregation Transformer for Image Restoration"
Apache License 2.0
121 stars 8 forks source link

Cross Aggregation Transformer for Image Restoration

Zheng Chen, Yulun Zhang, Jinjin Gu, Yongbing Zhang, Linghe Kong, and Xin Yuan, "Cross Aggregation Transformer for Image Restoration", NeurIPS, 2022 (Spotlight)

[paper] [arXiv] [supplementary material] [visual results] [pretrained models]


Abstract: Recently, Transformer architecture has been introduced into image restoration to replace convolution neural network (CNN) with surprising results. Considering the high computational complexity of Transformer with global attention, some methods use the local square window to limit the scope of self-attention. However, these methods lack direct interaction among different windows, which limits the establishment of long-range dependencies. To address the above issue, we propose a new image restoration model, Cross Aggregation Transformer (CAT). The core of our CAT is the Rectangle-Window Self-Attention (Rwin-SA), which utilizes horizontal and vertical rectangle window attention in different heads parallelly to expand the attention area and aggregate the features cross different windows. We also introduce the Axial-Shift operation for different window interactions. Furthermore, we propose the Locality Complementary Module to complement the self-attention mechanism, which incorporates the inductive bias of CNN (e.g., translation invariance and locality) into Transformer, enabling global-local coupling. Extensive experiments demonstrate that our CAT outperforms recent state-of-the-art methods on several image restoration applications.


SR (x4) HQ LQ SwinIR CAT (ours)

Dependencies

# Clone the github repo and go to the default directory 'CAT'.
git clone https://github.com/zhengchen1999/CAT.git
conda create -n CAT python=3.8
conda activate CAT
pip install -r requirements.txt
python setup.py develop

TODO

Contents

  1. Datasets
  2. Models
  3. Training
  4. Testing
  5. Results
  6. Citation
  7. Acknowledgements

Datasets

Used training and testing sets can be downloaded as follows:

Task Training Set Testing Set Visual Results
image SR DIV2K (800 training images, 100 validation images) + Flickr2K (2650 images) [complete training dataset DF2K] Set5 + Set14 + BSD100 + Urban100 + Manga109 [complete testing dataset download] here
grayscale JPEG compression artifact reduction DIV2K (800 training images) + Flickr2K (2650 images) + WED(4744 images) + BSD500 (400 training&testing images) [complete training dataset DFWB] Classic5 +LIVE + Urban100 [complete testing dataset download] here
real image denoising SIDD (320 training images) [complete training dataset SIDD] SIDD + DND [complete testing dataset download] here

Here the visual results are generated under SR (x4), JPEG compression artifact reduction (q10), and real image denoising.

Download training and testing datasets and put them into the corresponding folders of datasets/ and restormer/datasets. See datasets for the detail of directory structure.

Models

Task Method Params (M) FLOPs (G) Dataset PSNR (dB) SSIM Model Zoo Visual Results
SR CAT-R 16.60 292.7 Urban100 27.45 0.8254 Google Drive Google Drive
SR CAT-A 16.60 360.7 Urban100 27.89 0.8339 Google Drive Google Drive
SR CAT-R-2 11.93 216.3 Urban100 27.59 0.8285 Google Drive Google Drive
SR CAT-A-2 16.60 387.9 Urban100 27.99 0.8357 Google Drive Google Drive
CAR CAT 16.20 346.4 LIVE1 29.89 0.8295 Google Drive Google Drive
real-DN CAT 25.77 53.2 SIDD 40.01 0.9600 Google Drive Google Drive

The performance is reported on Urban100 (x4, SR), LIVE1 (q=10, CAR), and SIDD (real-DN). The test input size of FLOPs is 128 x 128.

Training

Image SR

JPEG Compression Artifact Reduction

Real Image Denoising

Testing

Image SR

JPEG Compression Artifact Reduction

Real Image Denoising

Results

We achieved state-of-the-art performance on image SR, JPEG compression artifact reduction and real image denoising. Detailed results can be found in the paper. All visual results of CAT can be downloaded here.

Image SR (click to expand) - results in Table 2 of the main paper

- results in Table 1 of the supplementary material

- visual comparison (x4) in the main paper

- visual comparison (x4) in the supplementary material

JPEG Compression Artifact Reduction (click to expand) - results in Table 3 of the main paper

- results in Table 3 of the supplementary material (test on **Urban100**)

- visual comparison (q=10) in the main paper

- visual comparison (q=10) in the supplementary material

Real Image Denoising (click to expand) - results in Table 4 of the main paper

*: We re-test the SIDD with all official pre-trained models.

Citation

If you find the code helpful in your resarch or work, please cite the following paper(s).

@inproceedings{chen2022cross,
    title={Cross Aggregation Transformer for Image Restoration},
    author={Chen, Zheng and Zhang, Yulun and Gu, Jinjin and Zhang, Yongbing and Kong, Linghe and Yuan, Xin},
    booktitle={NeurIPS},
    year={2022}
}

Acknowledgements

This code is built on BasicSR and Restormer.