SPSR

October 12, 2021 ยท View on GitHub

PyTorch implementation of Structure-Preserving Super Resolution with Gradient Guidance (CVPR 2020) [arXiv][CVF]

Extended version: Structure-Preserving Image Super-Resolution (TPAMI 2021) [arXiv]

If you find our work useful in your research, please consider citing:

@ARTICLE{ma2021structure,  
  author={Ma, Cheng and Rao, Yongming and Lu, Jiwen and Zhou, Jie},  
  journal={IEEE Transactions on Pattern Analysis and Machine Intelligence},   
  title={Structure-Preserving Image Super-Resolution},   
  year={2021},  
  volume={},  
  number={},  
  pages={1-1},  
  doi={10.1109/TPAMI.2021.3114428}}

@inproceedings{ma2020structure,
  title={Structure-Preserving Super Resolution with Gradient Guidance},
  author={Ma, Cheng and Rao, Yongming and Cheng, Yean and Chen, Ce and Lu, Jiwen and Zhou, Jie},
  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
  year={2020}
}

Dependencies

  • Python 3 (Recommend to use Anaconda)
  • PyTorch >= 1.0
  • NVIDIA GPU + CUDA
  • Python packages: pip install numpy opencv-python lmdb pyyaml
  • TensorBoard:
    • PyTorch >= 1.1: pip install tb-nightly future
    • PyTorch == 1.0: pip install tensorboardX

Dataset Preparation

Download Datasets

Commonly used training and testing datasets can be downloaded here.

Preprocess Datasets

We also provide code to preprocess the datasets here.

  • After downloading the original datasets, please store them to a specific GT folder.

  • You can obtain the LR, HR and Bicubic-upsampled versions of the datasets.

  • Then you can extract sub-images with unified scales for training.

  • The training sets can also be transformed into LMDB format for faster IO speed.

Training

To train an SPSR model:

python train.py -opt options/train/train_spsr.json

  • The json file will be processed by options/options.py. Please refer to this for more details.

  • Before running this code, please modify train_spsr.json to your own configurations including:

    • the proper dataroot_HR and dataroot_LR paths for the data loader (More details)
    • saving frequency for models and states
    • whether to resume training with .state files
    • other hyperparameters
    • loss function, etc.
  • You can find your training results in ./experiments.

  • During training, you can use Tesorboard to monitor the losses with tensorboard --logdir tb_logger/NAME_OF_YOUR_EXPERIMENT

  • You can choose to use a pretrained RRDB model as a parameter initialization by setting the pretrain_model_G option in options/train/train_spsr.json. Please download the pretrained model from Google Drive or Baidu Drive (extraction code muw3) and place RRDB_PSNR_x4.pth into ./experiments/pretrain_models.

Testing

To generate SR images by an SPSR model:

python test.py -opt options/test/test_spsr.json

  • Similar to training, the configurations can be modified in the test_spsr.json file.

  • You can find your results in ./results.

  • We provide our SPSR model used in our paper that can be downloaded in Google Drive or Baidu Drive (extraction code muw3). Download spsr.pth and put it into ./experiments/pretrain_models. Then modify the directory of pretrained model in test_spsr.json and run test.py.

  • You can put your own LR images in a certain folder and just change the dataroot_LR setting in test_spsr.json and run test.py.

Evaluation Toolbox

We provide an easy and useful evaluation toolbox to simplify the procedure of evaluating SR results. In this toolbox, you can get the MA, NIQE, PI, PSNR, SSIM, MSE, RMSE, MAE and LPIPS values of any SR results you want to evaluate.

Results

Visual Results

Quantitative Results

From the below two tables of comparison with perceptual-driven SR methods, we can see our SPSR method is able to obtain the best PI and LPIPS performance and comparable PSNR and SSIM values simultaneously. The top 2 scores are highlighted.

PI/LPIPS comparison with perceptual-driven SR methods.

MethodSet5Set14BSD100General100Urban100
Bicubic7.3699/0.34077.0268/0.43937.0026/0.52497.9365/0.35286.9435/0.4726
SFTGAN3.7587/0.08902.9063/0.14812.3774/0.17694.2878/0.10303.6136/0.1433
SRGAN3.9820/0.08823.0851/0.16632.5459/0.19804.3757/0.10553.6980/0.1551
ESRGAN3.7522/0.07482.9261/0.13292.4793/0.16144.3234/0.08793.7704/0.1229
NatSR4.1648/0.09393.1094/0.17582.7801/0.21144.6262/0.11173.6523/0.1500
SPSR3.2743/0.06442.9036/0.13182.3510/0.16114.0991/0.08633.5511/0.1184

PSNR/SSIM comparison with perceptual-driven SR methods.

MethodSet5Set14BSD100General100Urban100
Bicubic28.420/0.824526.100/0.785025.961/0.667528.018/0.828223.145/0.9011
SFTGAN29.932/0.866526.223/0.785425.505/0.654929.026/0.850824.013/0.9364
SRGAN29.168/0.861326.171/0.784125.459/0.648528.575/0.854124.397/0.9381
ESRGAN30.454/0.867726.276/0.778325.317/0.650629.412/0.854624.360/0.9453
NatSR30.991/0.880027.514/0.814026.445/0.683130.346/0.872125.464/0.9505
SPSR30.400/0.862726.640/0.793025.505/0.657629.414/0.853724.799/0.9481

Acknowledgement

The code is based on BasicSR, MA, NIQE, PI, SSIM and LPIPS.

Contact

If you have any questions about our work, please contact macheng17@mails.tsinghua.edu.cn