Skip to content
/ swin2sr Public

[ECCV] Swin2SR: SwinV2 Transformer for Compressed Image Super-Resolution and Restoration. Advances in Image Manipulation (AIM) workshop ECCV 2022. Try it out! over 3.3M runshttps://replicate /mv-lab/swin2sr

License

Notifications You must be signed in to change notification settings

mv-lab/swin2sr

Repository files navigation

Swin2SR @ ECCV 2022 AIM Workshop

arXiv visitors google colab logo Hugging Face Spaces kaggle logo


Marcos V. Conde,Ui-Jin Choi,Maxime Burchi,Radu Timofte

Computer Vision Lab, CAIDAS, University of Würzburg| MegaStudyEdu, South Korea

TLDR: Photorealistic super-resolution of compressed images using transformers / neural networks.

AtAISPthere is more work on image processing, low-level vision and computational photography.


News 🚀🚀

swin2sr-replicate


This is the official repository and PyTorch implementation of Swin2SR. We provide the supplementary material, code, pretrained models and demos. Swin2SR represents a possible improvement of the famousSwinIRbyJingyun Liang(kudos for such an amazing contribution ✋). Our model achieves state-of-the-art performance in:

swin2sr

Compression plays an important role on the efficient transmission and storage of images and videos through band-limited systems such as streaming services, virtual reality or videogames. However, compression unavoidably leads to artifacts and the loss of the original information, which may severely degrade the visual quality. For these reasons, quality enhancement of compressed images has become a popular research topic. While most state-of-the-art image restoration methods are based on convolutional neural networks, other transformers-based methods such as SwinIR, show impressive performance on these tasks. In this paper, we explore the novel Swin Transformer V2, to improve SwinIR for image super-resolution, and in particular, the compressed input scenario. Using this method we can tackle the major issues in training transformer vision models, such as training instability, resolution gaps between pre-training and fine-tuning, and hunger on data. We conduct experiments on three representative tasks: JPEG compression artifacts removal, image super-resolution (classical and lightweight), and compressed image super-resolution. Experimental results demonstrate that our method, Swin2SR, can improve the training convergence and performance of SwinIR, and is a top-5 solution at the "AIM 2022 Challenge on Super-Resolution of Compressed Image and Video".


Contents

  1. Training
  2. Results
  3. Demos
  4. Testing
  5. Citation and Acknowledgement
  6. Contact

Training

The training code is atKAIR.We follow the same training setup asSwinIRbyJingyun Liang.We are working on KAIR integration 👀 More details about the training setup in ourpaper.

Why moving to Swin Transformer V2?? paper swinv2 Especially in the case of lightweight super-resolution, we noticed how our model convergence was approximately x2 faster using the same experimental setup as SwinIR. We provide the details in the paper Section 3 and 4.2

Please check ourdemosready to run🚀


Results

We achieved state-of-the-art performance on classical, lightweight and real-world image Super-Resolution (SR), JPEG compression artifact reduction, and compressed input super-resolution. We use mainly the DIV2K Dataset and Flickr2K datasets for training, and for testing: RealSRSet, 5images/Classic5/Set5, Set14, BSD100, Urban100 and Manga109

🌎All visual results of Swin2SR can be downloaded here.We also provide links to download the original datasets. More details in ourpaper.


Compressed inputs Swin2SR output
frog_in frog_swin2sr
div2k_in div2k_swin2sr
buildings_in buildings_swin2sr

swin2sr makima demo

swin2sr makima demo


🌎All the qualitative samples can be downloaded here

Basic inference setup

  1. create a folderinputsand put there the input images. The model expects low-quality and low-resolution JPEG compressed images.

  2. select--scalestandard is 4, this means we will increase the resolution of the image x4 times. For example for a 1MP image (1000x1000) we will upscale it to near 4K (4000x4000).

  3. run our model usingmain_test_swin2sr.pyand--save_img_only.The pre-trained models are included inour repo,you can download them fromhereor check the reporeleases.It is important to select the proper--task,by default we do compressed input super-resolutioncompressed_s.

  4. we process the images ininputs/and the outputs are stored inresults/swin2sr_{TASK}_x{SCALE}where TASK and SCALE are the selected options. You can just navigate throughresults/

Python main_test_swin2sr.py --task compressed_sr --scale 4 --training_patch_size 48 --model_path model_zoo/swin2sr/Swin2SR_CompressedSR_X4_48.pth --folder_lq./inputs --save_img_only

toreproduce results,calculate metrics and further evaluation, please check the following sectionTesting.


Demos

🔥 🚀 ✅Kaggle kernel demoready to run!easy to follow includes testing for multiple SR applications.

Clicke here to see how the Kaggle demo looks like

kaggle demo


Super-Resolution Demo Swin2SR Officialis also available inGoogle Colabgoogle colab logo

We also have aninteractive demo, no login required!inHuggingface Spaces 🤗just click and upload images.

swin2sr huggingface demo

We are working on more interactive demos 👀 Contact us if you have ideas!



Testing

Theoriginal evaluation datasetscan be downloaded from the followingKaggle Dataset

sr-benchmarks

Classical image super-resolution (SR) Set5 + Set14 + BSD100 + Urban100 + Manga109 -download here

real-world image SR RealSRSet and 5images-download here

grayscale/color JPEG compression artifact reduction Classic5 +LIVE1 -download here

We follow the same evaluation setup asSwinIRbyJingyun Liang

🚀 You can check this evaluation process (and the followinf points) in our interactive kernelOfficial Swin2SR Demo Results


ClassicalSR

Python main_test_swin2sr.py --task classical_sr --scale 2 --training_patch_size 64 --model_path model_zoo/swin2sr/Swin2SR_ClassicalSR_X2_64.pth --folder_lq testsets/Set5/LR_bicubic/X2 --folder_gt testsets/Set5/HR

Python main_test_swin2sr.py --task classical_sr --scale 4 --training_patch_size 64 --model_path model_zoo/swin2sr/Swin2SR_ClassicalSR_X4_64.pth --folder_lq testsets/Set5/LR_bicubic/X4 --folder_gt testsets/Set5/HR

Lightweight

Python main_test_swin2sr.py --task lightweight_sr --scale 2 --training_patch_size 64 --model_path model_zoo/swin2sr/Swin2SR_Lightweight_X2_64.pth --folder_lq testsets/Set5/LR_bicubic/X2 --folder_gt testsets/Set5/HR

RealSR

Python main_test_swin2sr.py --task real_sr --scale 4 --model_path model_zoo/swin2sr/Swin2SR_RealworldSR_X4_64_BSRGAN_PSNR.pth --folder_lq testsets/RealSRSet+5images

CompressedSR

Python main_test_swin2sr.py --task compressed_sr --scale 4 --training_patch_size 48 --model_path model_zoo/swin2sr/Swin2SR_CompressedSR_X4_48.pth --folder_gt path/to/DIV2K_Valid_HR --folder_lq /path/to/DIV2K_Valid_LR/Compressed_X4

JPEG Compression Artifact Reduction, Dynamic, GrayScale

Python main_test_swin2sr.py --task jpeg_car --jpeg 10 --model_path model_zoo/swin2sr/Swin2SR_Jpeg_dynamic.pth --folder_gt /path/to/classic5
Python main_test_swin2sr.py --task jpeg_car --jpeg 20 --model_path model_zoo/swin2sr/Swin2SR_Jpeg_dynamic.pth --folder_gt /path/to/classic5
Python main_test_swin2sr.py --task jpeg_car --jpeg 30 --model_path model_zoo/swin2sr/Swin2SR_Jpeg_dynamic.pth --folder_gt /path/to/classic5
Python main_test_swin2sr.py --task jpeg_car --jpeg 40 --model_path model_zoo/swin2sr/Swin2SR_Jpeg_dynamic.pth --folder_gt /path/to/classic5

Related Work

SwinIR: Image Restoration Using Swin Transformerby Liang et al, ICCVW 2021.

AISP: AI Image Signal Processingby Marcos Conde, Radu Timofte and collaborators, 2022.

AIM 2022 Challenge on Super-Resolution of Compressed Image and Videoorganized by Ren Yang.

Swin Transformer V2: Scaling Up Capacity and Resolutionby Liu et al, CVPR 2022.


Citation and Acknowledgement

@inproceedings{conde2022swin2sr,
title={{S}win2{SR}: SwinV2 Transformer for Compressed Image Super-Resolution and Restoration},
author={Conde, Marcos V and Choi, Ui-Jin and Burchi, Maxime and Timofte, Radu},
booktitle={Proceedings of the European Conference on Computer Vision (ECCV) Workshops},
year={2022}
}

@article{liang2021swinir,
title={SwinIR: Image Restoration Using Swin Transformer},
author={Liang, Jingyun and Cao, Jiezhang and Sun, Guolei and Zhang, Kai and Van Gool, Luc and Timofte, Radu},
journal={arXiv preprint arXiv:2108.10257},
year={2021}
}

This project is released under the Apache 2.0 license. The codes are heavily based onSwin TransformerandSwinV2 TransformerbyZe Liu.We also refer to codes inKAIR,BasicSRandSwinIR.Please also follow their licenses. Thanks for their awesome works.

Contact

Marcos Conde ([email protected]) and Ui-Jin Choi (choiuijin1125@gmail) are the contact persons. Please add in the email subject "swin2sr".