Swin2sr
[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 runs https://replicate.com/mv-lab/swin2sr
Install / Use
/learn @mv-lab/Swin2srREADME
Swin2SR @ ECCV 2022 AIM Workshop
Swin2SR: SwinV2 Transformer for Compressed Image Super-Resolution and Restoration
<a href="https://colab.research.google.com/drive/1paPrt62ydwLv2U2eZqfcFsePI4X4WRR1?usp=sharing"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="google colab logo"></a>
<a href="https://www.kaggle.com/code/jesucristo/super-resolution-demo-swin2sr-official/"><img src="https://upload.wikimedia.org/wikipedia/commons/7/7c/Kaggle_logo.png?20140912155123" alt="kaggle logo" width=50></a>
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.
At AISP there is more work on image processing, low-level vision and computational photography.
News 🚀🚀
- [06/2023] Researchers from the Technion–Israel Institute of Technology use Swin2SR in a novel work "Deep Optimal Transport: A Practical Algorithm for Photo-realistic Image Restoration"
- [06/2023] After 7 months, the online app reached 1.8 million runs on replicate! Try it out
- [01/2023] Swin2SR is integrated into Stable Difussion webui by AUTOMATIC1111
- [10/2022] Demos on Kaggle, Collab and Huggingface Spaces 🤗 are ready!
- [09/2022] Ongoing website and multiple demos creation. Feel free to contact us. Paper will be presented at the Advances in Image Manipulation (AIM) workshop, ECCV 2022, Tel Aviv.
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 famous SwinIR by Jingyun Liang (kudos for such an amazing contribution ✋). Our model achieves state-of-the-art performance in:
- classical, lighweight and real-world image super-resolution (SR)
- color JPEG compression artifact reduction
- compressed input super-resolution: top solution at the "AIM 2022 Challenge on Super-Resolution of Compressed Image and Video" organized by Ren Yang and Radu Timofte
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
Training
The training code is at KAIR. We follow the same training setup as SwinIR by Jingyun Liang. We are working on KAIR integration 👀 More details about the training setup in our paper.
<details> <summary><b>Why moving to Swin Transformer V2 ??</b></summary> <img src="media/paper-why.png " alt="paper swinv2" width="800" border="0"> 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 </details> <br>Please check our demos ready 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 our paper.
<br>|Compressed inputs | Swin2SR output| | :--- | :---: | | <img src="media/frog_0.png" alt="frog_in" width="300" border="0"> | <img src="media/frog_1.png" alt="frog_swin2sr" width="300" border="0"> | | <img src="media/0814_0.png" alt="div2k_in" width="300" border="0"> | <img src="media/0814_1.png" alt="div2k_swin2sr" width="300" border="0"> | | <img src="media/buildings_0.png" alt="buildings_in" width="300" border="0"> | <img src="media/buildings_1.png" alt="buildings_swin2sr" width="300" border="0"> |
<img src="media/chain-sample.png " alt="swin2sr makima demo" width="620" border="0"> <img src="media/gojou-sample.png " alt="swin2sr makima demo" width="620" border="0"> <br>🌎 All the qualitative samples can be downloaded here
Basic inference setup
-
create a folder
inputsand put there the input images. The model expects low-quality and low-resolution JPEG compressed images. -
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). -
run our model using
main_test_swin2sr.pyand--save_img_only. The pre-trained models are included in our repo, you can download them from here or check the repo releases. It is important to select the proper--task, by default we do compressed input super-resolutioncompressed_s. -
we process the images in
inputs/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
to reproduce results, calculate metrics and further evaluation, please check the following section Testing.
Demos
🔥 🚀 ✅ Kaggle kernel demo ready to run! easy to follow includes testing for multiple SR applications.
<details> <summary>Clicke here to see how the Kaggle demo looks like</summary> <p align="center"> <img src="media/kaggle-demo.png " alt="kaggle demo" width="800" border="0"> </p> </details> <br>Super-Resolution Demo Swin2SR Official is also available in <a href="https://colab.research.google.com/drive/1paPrt62ydwLv2U2eZqfcFsePI4X4WRR1?usp=sharing">Google Colab <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="google colab logo"></a>
We also have an interactive demo, no login required! in Huggingface Spaces 🤗 just click and upload images.
<img src="media/hug-demo.png" alt="swin2sr huggingface demo" width="800" border=
