Zdafeng/SwinFIR

Python

97

8 commits

updated May 20, 2024

See the code

README

PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC

SwinFIR: Revisiting the SwinIR with Fast Fourier Convolution and Improved Training for Image Super-Resolution

Dafeng Zhang, Feiyu Huang, Shizhuo Liu, Xiaobing Wang and Zhezhu Jin

Transformer-based methods have achieved impressive image restoration performance due to their capacities to model long-range dependency compared to CNN-based methods. However, advances like SwinIR adopts the window-based and local attention strategy to balance the performance and computational overhead, which restricts employing large receptive fields to capture global information and establish long dependencies in the early layers. To further improve the efficiency of capturing global information, in this work, we propose SwinFIR to extend SwinIR by replacing Fast Fourier Convolution (FFC) components, which have the image-wide receptive field. We also revisit other advanced techniques, i.e., data augmentation, pre-training, and feature ensemble to improve the effect of image reconstruction. And our feature ensemble method enables the performance of the model to be considerably enhanced without increasing the training and testing time. We applied our algorithm on multiple popular large-scale benchmarks and achieved state-of-the-art performance comparing to the existing methods. For example, our SwinFIR achieves the PSNR of 32.83 dB on Manga109 dataset, which is 0.8 dB higher than the state-of-the-art SwinIR method, a significant improvement.

Architecture

Environment

Installation

Install Pytorch first. Then,

pip install -r requirements.txt
python setup.py develop

How To Inference

Single Image Super Resolution

python inference/inference_swinfir.py

Stereo Image Super Resolution

python inference/inference_swinfirssr.py

How To Test

SwinFIR and HATFIR for single image super resolution

SwinFIRSSR for stereo image super resolution

Single Image Super Resolution

  • Prepare the testing data according to HAT for single image super resolution.
  • Download the pretrained model, Google Drive or Baidu Netdisk (access code: 8i4g).
  • Then run the follwing codes (taking SwinFIR_SRx4.yml as an example):
python swinfir/test.py -opt options/test/SwinFIR/SwinFIR_SRx4.yml

Stereo Image Super Resolution

  • Prepare the testing data according to NAFSSR for stereo image super resolution.
  • Download the pretrained model, Google Drive or Baidu Netdisk (access code: 8i4g).
  • Then run the follwing codes (taking SwinFIRSSR_SSRx4.yml as an example):
python swinfir/test.py -opt options/test/SwinFIRSSR/SwinFIRSSR_SSRx4.yml

How To Train

  • Refer to ./options/train for the configuration file of the model to train.
  • Preparation of training data can refer to this page. ImageNet dataset can be downloaded at the official website.
  • The training command is like
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 --master_port=4321 swinfir/train.py -opt options/train/SwinFIR/train_SwinFIR_SRx2_from_scratch.yml --launcher pytorch

The training logs and weights will be saved in the ./experiments folder.

Results

  • Classical Image Super-Resolution

    MethodScaleSet5Set14BSD100Urban100Manga109
    SwinIRX238.4234.4632.5333.8139.92
    SwinFIRX238.6734.9432.6634.5940.63
    HATX233.7335.1332.6934.8140.71
    HATFIRX238.7735.1932.7334.9740.78
    SwinIRX334.9730.9329.4629.7535.12
    SwinFIRX335.1631.2529.5630.4535.77
    HATX335.1631.3329.5930.7035.84
    HATFIRX335.2231.3729.6130.7835.91
    SwinIRX432.9229.0927.9227.4532.03
    SwinFIRX433.2029.3628.0328.1432.84
    HATX433.1829.3828.0528.3732.87
    HATFIRX433.2929.4728.0828.4433.03
  • Lightweight Image Super-Resolution

    MethodScaleSet5Set14BSD100Urban100Manga109
    SwinIRX238.1433.8632.3132.7639.12
    SwinFIRX238.3034.2832.4333.3339.71
    SwinIRX334.6230.5429.2028.6633.98
    SwinFIRX334.7630.6829.3029.0534.59
    SwinIRX432.4428.7727.6926.4730.92
    SwinFIRX432.6728.9927.8026.9931.68
  • Stereo Image Super-Resolution

    MethodScaleKITTI 2012KITTI 2015MiddleburyFlickr 1024
    NAFSSR-LX231.6031.2535.8829.68
    SwinFIRSSRX231.7931.4536.5230.14
    NAFSSR-LX427.1226.9630.3024.17
    SwinFIRSSRX427.1626.8930.4424.30

Citation

If you find this project useful for your research, please consider citing:

@article{zhang2022swinfir,
  title={Swinfir: Revisiting the swinir with fast fourier convolution and improved training for image super-resolution},
  author={Zhang, Dafeng and Huang, Feiyu and Liu, Shizhuo and Wang, Xiaobing and Jin, Zhezhu},
  journal={arXiv preprint arXiv:2208.11247},
  year={2022}
}

Acknowledgement

This project is mainly based on BasicSR and HAT.

Zdafeng/SwinFIR

Python

97

8 commits

updated May 20, 2024

See the code

README

PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC PWC

SwinFIR: Revisiting the SwinIR with Fast Fourier Convolution and Improved Training for Image Super-Resolution

Dafeng Zhang, Feiyu Huang, Shizhuo Liu, Xiaobing Wang and Zhezhu Jin

Transformer-based methods have achieved impressive image restoration performance due to their capacities to model long-range dependency compared to CNN-based methods. However, advances like SwinIR adopts the window-based and local attention strategy to balance the performance and computational overhead, which restricts employing large receptive fields to capture global information and establish long dependencies in the early layers. To further improve the efficiency of capturing global information, in this work, we propose SwinFIR to extend SwinIR by replacing Fast Fourier Convolution (FFC) components, which have the image-wide receptive field. We also revisit other advanced techniques, i.e., data augmentation, pre-training, and feature ensemble to improve the effect of image reconstruction. And our feature ensemble method enables the performance of the model to be considerably enhanced without increasing the training and testing time. We applied our algorithm on multiple popular large-scale benchmarks and achieved state-of-the-art performance comparing to the existing methods. For example, our SwinFIR achieves the PSNR of 32.83 dB on Manga109 dataset, which is 0.8 dB higher than the state-of-the-art SwinIR method, a significant improvement.

Architecture

Environment

Installation

Install Pytorch first. Then,

pip install -r requirements.txt
python setup.py develop

How To Inference

Single Image Super Resolution

python inference/inference_swinfir.py

Stereo Image Super Resolution

python inference/inference_swinfirssr.py

How To Test

SwinFIR and HATFIR for single image super resolution

SwinFIRSSR for stereo image super resolution

Single Image Super Resolution

  • Prepare the testing data according to HAT for single image super resolution.
  • Download the pretrained model, Google Drive or Baidu Netdisk (access code: 8i4g).
  • Then run the follwing codes (taking SwinFIR_SRx4.yml as an example):
python swinfir/test.py -opt options/test/SwinFIR/SwinFIR_SRx4.yml

Stereo Image Super Resolution

  • Prepare the testing data according to NAFSSR for stereo image super resolution.
  • Download the pretrained model, Google Drive or Baidu Netdisk (access code: 8i4g).
  • Then run the follwing codes (taking SwinFIRSSR_SSRx4.yml as an example):
python swinfir/test.py -opt options/test/SwinFIRSSR/SwinFIRSSR_SSRx4.yml

How To Train

  • Refer to ./options/train for the configuration file of the model to train.
  • Preparation of training data can refer to this page. ImageNet dataset can be downloaded at the official website.
  • The training command is like
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python -m torch.distributed.launch --nproc_per_node=8 --master_port=4321 swinfir/train.py -opt options/train/SwinFIR/train_SwinFIR_SRx2_from_scratch.yml --launcher pytorch

The training logs and weights will be saved in the ./experiments folder.

Results

  • Classical Image Super-Resolution

    MethodScaleSet5Set14BSD100Urban100Manga109
    SwinIRX238.4234.4632.5333.8139.92
    SwinFIRX238.6734.9432.6634.5940.63
    HATX233.7335.1332.6934.8140.71
    HATFIRX238.7735.1932.7334.9740.78
    SwinIRX334.9730.9329.4629.7535.12
    SwinFIRX335.1631.2529.5630.4535.77
    HATX335.1631.3329.5930.7035.84
    HATFIRX335.2231.3729.6130.7835.91
    SwinIRX432.9229.0927.9227.4532.03
    SwinFIRX433.2029.3628.0328.1432.84
    HATX433.1829.3828.0528.3732.87
    HATFIRX433.2929.4728.0828.4433.03
  • Lightweight Image Super-Resolution

    MethodScaleSet5Set14BSD100Urban100Manga109
    SwinIRX238.1433.8632.3132.7639.12
    SwinFIRX238.3034.2832.4333.3339.71
    SwinIRX334.6230.5429.2028.6633.98
    SwinFIRX334.7630.6829.3029.0534.59
    SwinIRX432.4428.7727.6926.4730.92
    SwinFIRX432.6728.9927.8026.9931.68
  • Stereo Image Super-Resolution

    MethodScaleKITTI 2012KITTI 2015MiddleburyFlickr 1024
    NAFSSR-LX231.6031.2535.8829.68
    SwinFIRSSRX231.7931.4536.5230.14
    NAFSSR-LX427.1226.9630.3024.17
    SwinFIRSSRX427.1626.8930.4424.30

Citation

If you find this project useful for your research, please consider citing:

@article{zhang2022swinfir,
  title={Swinfir: Revisiting the swinir with fast fourier convolution and improved training for image super-resolution},
  author={Zhang, Dafeng and Huang, Feiyu and Liu, Shizhuo and Wang, Xiaobing and Jin, Zhezhu},
  journal={arXiv preprint arXiv:2208.11247},
  year={2022}
}

Acknowledgement

This project is mainly based on BasicSR and HAT.