{"id":15025873,"url":"https://github.com/jingyunliang/swinir","last_synced_at":"2025-05-14T14:08:41.306Z","repository":{"id":37793626,"uuid":"396770997","full_name":"JingyunLiang/SwinIR","owner":"JingyunLiang","description":"SwinIR: Image Restoration Using Swin Transformer (official repository)","archived":false,"fork":false,"pushed_at":"2024-05-14T07:05:48.000Z","size":30550,"stargazers_count":4827,"open_issues_count":73,"forks_count":576,"subscribers_count":50,"default_branch":"main","last_synced_at":"2025-05-03T20:35:20.749Z","etag":null,"topics":["compression-artifact-reduction","deblocking","decompression","denoising","image-deblocking","image-denoising","image-restoration","image-sr","image-super-resolution","lightweight-image-super-resolution","low-level-vision","real-world-image-super-resolution","restoration","super-resolution","transformer","vision-transformer"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2108.10257","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JingyunLiang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-16T11:50:30.000Z","updated_at":"2025-05-03T11:36:10.000Z","dependencies_parsed_at":"2023-01-22T23:16:21.185Z","dependency_job_id":"49ce03dd-8ae8-4bf4-981d-1ba53322bcc3","html_url":"https://github.com/JingyunLiang/SwinIR","commit_stats":{"total_commits":65,"total_committers":7,"mean_commits":9.285714285714286,"dds":"0.15384615384615385","last_synced_commit":"6545850fbf8df298df73d81f3e8cba638787c8bd"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingyunLiang%2FSwinIR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingyunLiang%2FSwinIR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingyunLiang%2FSwinIR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingyunLiang%2FSwinIR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JingyunLiang","download_url":"https://codeload.github.com/JingyunLiang/SwinIR/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254160441,"owners_count":22024569,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compression-artifact-reduction","deblocking","decompression","denoising","image-deblocking","image-denoising","image-restoration","image-sr","image-super-resolution","lightweight-image-super-resolution","low-level-vision","real-world-image-super-resolution","restoration","super-resolution","transformer","vision-transformer"],"created_at":"2024-09-24T20:03:12.212Z","updated_at":"2025-05-14T14:08:41.277Z","avatar_url":"https://github.com/JingyunLiang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwinIR: Image Restoration Using Swin Transformer\n[Jingyun Liang](https://jingyunliang.github.io), [Jiezhang Cao](https://www.jiezhangcao.com/), [Guolei Sun](https://vision.ee.ethz.ch/people-details.MjYzMjMw.TGlzdC8zMjg5LC0xOTcxNDY1MTc4.html), [Kai Zhang](https://cszn.github.io/), [Luc Van Gool](https://scholar.google.com/citations?user=TwMib_QAAAAJ\u0026hl=en), [Radu Timofte](http://people.ee.ethz.ch/~timofter/)\n\nComputer Vision Lab, ETH Zurich\n\n---\n\n[![arXiv](https://img.shields.io/badge/arXiv-Paper-\u003cCOLOR\u003e.svg)](https://arxiv.org/abs/2108.10257)\n[![GitHub Stars](https://img.shields.io/github/stars/JingyunLiang/SwinIR?style=social)](https://github.com/JingyunLiang/SwinIR)\n[![download](https://img.shields.io/github/downloads/JingyunLiang/SwinIR/total.svg)](https://github.com/JingyunLiang/SwinIR/releases)\n![visitors](https://visitor-badge.glitch.me/badge?page_id=jingyunliang/SwinIR)\n[ \u003ca href=\"https://colab.research.google.com/gist/JingyunLiang/a5e3e54bc9ef8d7bf594f6fee8208533/swinir-demo-on-real-world-image-sr.ipynb\"\u003e\u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"google colab logo\"\u003e\u003c/a\u003e](https://colab.research.google.com/gist/JingyunLiang/a5e3e54bc9ef8d7bf594f6fee8208533/swinir-demo-on-real-world-image-sr.ipynb)\n\u003ca href=\"https://replicate.ai/jingyunliang/swinir\"\u003e\u003cimg src=\"https://img.shields.io/static/v1?label=Replicate\u0026message=Demo and Docker Image\u0026color=blue\"\u003e\u003c/a\u003e\n[![PlayTorch Demo](https://github.com/facebookresearch/playtorch/blob/main/website/static/assets/playtorch_badge.svg)](https://playtorch.dev/snack/@playtorch/swinir/)\n[Gradio Web Demo](https://huggingface.co/spaces/akhaliq/SwinIR)\n\nThis repository is the official PyTorch implementation of SwinIR: Image Restoration Using Shifted Window Transformer\n([arxiv](https://arxiv.org/pdf/2108.10257.pdf), [supp](https://github.com/JingyunLiang/SwinIR/releases), [pretrained models](https://github.com/JingyunLiang/SwinIR/releases), [visual results](https://github.com/JingyunLiang/SwinIR/releases)). SwinIR achieves **state-of-the-art performance** in\n- bicubic/lighweight/real-world image SR\n- grayscale/color image denoising\n- grayscale/color JPEG compression artifact reduction\n\n\u003c/br\u003e\n\n:rocket:  :rocket:  :rocket: **News**:\n- **Aug. 16, 2022**: Add PlayTorch Demo on running the real-world image SR model on mobile devices [![PlayTorch Demo](https://github.com/facebookresearch/playtorch/blob/main/website/static/assets/playtorch_badge.svg)](https://playtorch.dev/snack/@playtorch/swinir/).\n- **Aug. 01, 2022**: Add pretrained models and results on JPEG compression artifact reduction for color images. \n- **Jun. 10, 2022**: See our work on video restoration :fire::fire::fire: [VRT: A Video Restoration Transformer](https://github.com/JingyunLiang/VRT) \n[![GitHub Stars](https://img.shields.io/github/stars/JingyunLiang/VRT?style=social)](https://github.com/JingyunLiang/VRT)\n[![download](https://img.shields.io/github/downloads/JingyunLiang/VRT/total.svg)](https://github.com/JingyunLiang/VRT/releases)\nand [RVRT: Recurrent Video Restoration Transformer](https://github.com/JingyunLiang/RVRT) \n[![GitHub Stars](https://img.shields.io/github/stars/JingyunLiang/RVRT?style=social)](https://github.com/JingyunLiang/RVRT)\n[![download](https://img.shields.io/github/downloads/JingyunLiang/RVRT/total.svg)](https://github.com/JingyunLiang/RVRT/releases)\nfor video SR, video deblurring, video denoising, video frame interpolation and space-time video SR.\n- **Sep. 07, 2021**: We provide an interactive online Colab demo for real-world image SR \u003ca href=\"https://colab.research.google.com/gist/JingyunLiang/a5e3e54bc9ef8d7bf594f6fee8208533/swinir-demo-on-real-world-image-sr.ipynb\"\u003e\u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"google colab logo\"\u003e\u003c/a\u003e:fire: for comparison with [the first practical degradation model BSRGAN (ICCV2021) ![GitHub Stars](https://img.shields.io/github/stars/cszn/BSRGAN?style=social)](https://github.com/cszn/BSRGAN) and a recent model RealESRGAN. Try to super-resolve your own images on Colab!\n\n|Real-World Image (x4)|[BSRGAN, ICCV2021](https://github.com/cszn/BSRGAN)|[Real-ESRGAN](https://github.com/xinntao/Real-ESRGAN)|SwinIR (ours)|SwinIR-Large (ours)|\n|       :---       |     :---:        |        :-----:         |        :-----:         |        :-----:         | \n| \u003cimg width=\"200\" src=\"figs/ETH_LR.png\"\u003e|\u003cimg width=\"200\" src=\"figs/ETH_BSRGAN.png\"\u003e|\u003cimg width=\"200\" src=\"figs/ETH_realESRGAN.jpg\"\u003e|\u003cimg width=\"200\" src=\"figs/ETH_SwinIR.png\"\u003e|\u003cimg width=\"200\" src=\"figs/ETH_SwinIR-L.png\"\u003e\n|\u003cimg width=\"200\" src=\"figs/OST_009_crop_LR.png\"\u003e|\u003cimg width=\"200\" src=\"figs/OST_009_crop_BSRGAN.png\"\u003e|\u003cimg width=\"200\" src=\"figs/OST_009_crop_realESRGAN.png\"\u003e|\u003cimg width=\"200\" src=\"figs/OST_009_crop_SwinIR.png\"\u003e|\u003cimg width=\"200\" src=\"figs/OST_009_crop_SwinIR-L.png\"\u003e|\n  \n - ***Aug. 26, 2021**: See our recent work on [real-world image SR: a pratical degrdation model BSRGAN, ICCV2021](https://github.com/cszn/BSRGAN)\n[![GitHub Stars](https://img.shields.io/github/stars/cszn/BSRGAN?style=social)](https://github.com/cszn/BSRGAN)*\n - ***Aug. 26, 2021**: See our recent work on [generative modelling of image SR and image rescaling: normalizing-flow-based HCFlow, ICCV2021](https://github.com/JingyunLiang/HCFlow)\n[![GitHub Stars](https://img.shields.io/github/stars/JingyunLiang/HCFlow?style=social)](https://github.com/JingyunLiang/HCFlow)[ \u003ca href=\"https://colab.research.google.com/gist/JingyunLiang/cdb3fef89ebd174eaa43794accb6f59d/hcflow-demo-on-x8-face-image-sr.ipynb\"\u003e\u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"google colab logo\"\u003e\u003c/a\u003e](https://colab.research.google.com/gist/JingyunLiang/cdb3fef89ebd174eaa43794accb6f59d/hcflow-demo-on-x8-face-image-sr.ipynb)*\n - ***Aug. 26, 2021**: See our recent work on [blind SR: spatially variant kernel estimation (MANet, ICCV2021)](https://github.com/JingyunLiang/MANet) [![GitHub Stars](https://img.shields.io/github/stars/JingyunLiang/MANet?style=social)](https://github.com/JingyunLiang/MANet)\n[ \u003ca href=\"https://colab.research.google.com/gist/JingyunLiang/4ed2524d6e08343710ee408a4d997e1c/manet-demo-on-spatially-variant-kernel-estimation.ipynb\"\u003e\u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"google colab logo\"\u003e\u003c/a\u003e](https://colab.research.google.com/gist/JingyunLiang/4ed2524d6e08343710ee408a4d997e1c/manet-demo-on-spatially-variant-kernel-estimation.ipynb) and [unsupervised kernel estimation (FKP, CVPR2021)](https://github.com/JingyunLiang/FKP)\n[![GitHub Stars](https://img.shields.io/github/stars/JingyunLiang/FKP?style=social)](https://github.com/JingyunLiang/FKP)*\n\n---\n\n\u003e Image restoration is a long-standing low-level vision problem that aims to restore high-quality images from low-quality images (e.g., downscaled, noisy and compressed images). While state-of-the-art image restoration methods are based on convolutional neural networks, few attempts have been made with Transformers which show impressive performance on high-level vision tasks. In this paper, we propose a strong baseline model SwinIR for image restoration based on the Swin Transformer. SwinIR consists of three parts: shallow feature extraction, deep feature extraction and high-quality image reconstruction. In particular, the deep feature extraction module is composed of several residual Swin Transformer blocks (RSTB), each of which has several Swin Transformer layers together with a residual connection. We conduct experiments on three representative tasks: image super-resolution (including classical, lightweight and real-world image super-resolution), image denoising (including grayscale and color image denoising) and JPEG compression artifact reduction. Experimental results demonstrate that SwinIR outperforms state-of-the-art methods on different tasks by up to 0.14~0.45dB, while the total number of parameters can be reduced by up to 67%.\n\u003e\u003cp align=\"center\"\u003e\n  \u003cimg width=\"800\" src=\"figs/SwinIR_archi.png\"\u003e\n\u003c/p\u003e\n\n\n\n#### Contents\n\n1. [Training](#Training)\n1. [Testing](#Testing)\n1. [Results](#Results)\n1. [Citation](#Citation)\n1. [License and Acknowledgement](#License-and-Acknowledgement)\n\n\n### Training\n\n\nUsed training and testing sets can be downloaded as follows:\n\n| Task                                                |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Training Set                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Testing Set|    Visual Results |    \n|:----------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|     :---:      |   :---:      |\n| classical/lightweight image SR                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                               [DIV2K](https://cv.snu.ac.kr/research/EDSR/DIV2K.tar) (800 training images) or DIV2K +[Flickr2K](https://cv.snu.ac.kr/research/EDSR/Flickr2K.tar) (2650 images)                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Set5 + Set14 + BSD100 + Urban100 + Manga109 [download all](https://drive.google.com/drive/folders/1B3DJGQKB6eNdwuQIhdskA64qUuVKLZ9u) | [here](https://github.com/JingyunLiang/SwinIR/releases) |\n| real-world image SR                                 | SwinIR-M (middle size): [DIV2K](https://cv.snu.ac.kr/research/EDSR/DIV2K.tar) (800 training images) +[Flickr2K](https://cv.snu.ac.kr/research/EDSR/Flickr2K.tar) (2650 images) + [OST](https://openmmlab.oss-cn-hangzhou.aliyuncs.com/datasets/OST_dataset.zip) ([alternative link](https://drive.google.com/drive/folders/1iZfzAxAwOpeutz27HC56_y5RNqnsPPKr), 10324 images for sky,water,grass,mountain,building,plant,animal) \u003cbr /\u003e SwinIR-L (large size): DIV2K + Flickr2K + OST + [WED](http://ivc.uwaterloo.ca/database/WaterlooExploration/exploration_database_and_code.rar)(4744 images) + [FFHQ](https://drive.google.com/drive/folders/1tZUcXDBeOibC6jcMCtgRRz67pzrAHeHL) (first 2000 images, face) + Manga109 (manga) + [SCUT-CTW1500](https://universityofadelaide.box.com/shared/static/py5uwlfyyytbb2pxzq9czvu6fuqbjdh8.zip) (first 100 training images, texts) \u003cbr /\u003e\u003cbr /\u003e  ***We use the pionnerring practical degradation model from [BSRGAN, ICCV2021  ![GitHub Stars](https://img.shields.io/github/stars/cszn/BSRGAN?style=social)](https://github.com/cszn/BSRGAN)** | [RealSRSet+5images](https://github.com/JingyunLiang/SwinIR/releases/download/v0.0/RealSRSet+5images.zip) |  [here](https://github.com/JingyunLiang/SwinIR/releases) |\n| color/grayscale image denoising                     |                                                                                                                                                                                                                                                                                                             [DIV2K](https://cv.snu.ac.kr/research/EDSR/DIV2K.tar) (800 training images) + [Flickr2K](https://cv.snu.ac.kr/research/EDSR/Flickr2K.tar) (2650 images) + [BSD500](http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/BSR/BSR_bsds500.tgz) (400 training\u0026testing images) + [WED](http://ivc.uwaterloo.ca/database/WaterlooExploration/exploration_database_and_code.rar)(4744 images)  \u003cbr /\u003e\u003cbr /\u003e  *BSD68/BSD100 images are not used in training.                                                                                                                                                                                                                                                                                                              |  grayscale: Set12 + BSD68 + Urban100 \u003cbr /\u003e  color: CBSD68 + Kodak24 + McMaster + Urban100 [download all](https://github.com/cszn/FFDNet/tree/master/testsets) |  [here](https://github.com/JingyunLiang/SwinIR/releases) |\n| grayscale/color JPEG compression artifact reduction |                                                                                                                                                                                                                                                                                                                                            [DIV2K](https://cv.snu.ac.kr/research/EDSR/DIV2K.tar) (800 training images) + [Flickr2K](https://cv.snu.ac.kr/research/EDSR/Flickr2K.tar) (2650 images) + [BSD500](http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/BSR/BSR_bsds500.tgz) (400 training\u0026testing images) + [WED](http://ivc.uwaterloo.ca/database/WaterlooExploration/exploration_database_and_code.rar)(4744 images)                                                                                                                                                                                                                                                                                                                                             |  grayscale: Classic5 +LIVE1 [download all](https://github.com/cszn/DnCNN/tree/master/testsets) | [here](https://github.com/JingyunLiang/SwinIR/releases) |\n\n\n\u003c!--\n| Task                 | Training Set | Testing Set|        Pretrained Model and Visual Results of SwinIR     | \n| :---                 | :---:        |     :---:      |:---:      |\n| image denoising (real)      | [SIDD-Medium-sRGB](https://www.eecs.yorku.ca/~kamel/sidd/dataset.php) (320 images, [preprocess]()) + [RENOIR](http://ani.stat.fsu.edu/~abarbu/Renoir.html) (221 images, [preprocess](https://github.com/zsyOAOA/DANet/blob/master/datasets/preparedata/Renoir_big2small_all.py)) + [Poly](https://github.com/csjunxu/PolyU-Real-World-Noisy-Images-Dataset) (40 images in ./OriginalImages) |    [SIDD validation set](https://drive.google.com/drive/folders/1S44fHXaVxAYW3KLNxK41NYCnyX9S79su) (1280 patches, identical to official [.mat](https://www.eecs.yorku.ca/~kamel/sidd/benchmark.php) version) +  [DND](https://noise.visinf.tu-darmstadt.de/downloads/) (pre-defined 100 patches of 50 images, [online eval](https://noise.visinf.tu-darmstadt.de/submit/)) + [Nam](https://www.dropbox.com/s/24kds7c436i5i11/real_image_noise_dataset.zip?dl=0) (random 100 patches of 17 images, [preprocess](https://github.com/zsyOAOA/DANet/blob/master/datasets/preparedata/Nam_patch_prepare.py))|[download model]() [download results]() |\n| image deblurring (synthetic)   | [GoPro](https://drive.google.com/drive/folders/1AsgIP9_X0bg0olu2-1N6karm2x15cJWE) (2103 training images)  |  [GoPro](https://drive.google.com/drive/folders/1a2qKfXWpNuTGOm2-Jex8kfNSzYJLbqkf) (1111 images) + [HIDE](https://drive.google.com/drive/folders/1nRsTXj4iTUkTvBhTcGg8cySK8nd3vlhK) (2050 images) + [RealBlur_J](https://drive.google.com/drive/folders/1KYtzeKCiDRX9DSvC-upHrCqvC4sPAiJ1) (real blur, 980 images) + [RealBlur_R](https://drive.google.com/drive/folders/1EwDoajf5nStPIAcU4s9rdc8SPzfm3tW1) (real blur, 980 images) | [download model]() [download results]()|\n| image deraining (synthetic)  | [Multiple datasets](https://drive.google.com/drive/folders/1Hnnlc5kI0v9_BtfMytC2LR5VpLAFZtVe) (13711 training images, see Table 1 of [MPRNet](https://github.com/swz30/MPRNet) for details.)  |  Rain100H (100 images) + Rain100L (100 images) + Test100 (100 images) + Test2800 (2800 images) + Test1200 (1200 images), [download all](https://drive.google.com/drive/folders/1PDWggNh8ylevFmrjo-JEvlmqsDlWWvZs)  | [download model]() [download results]()|\n\nNote: above datasets may come from the official release or some awesome collections ([BasicSR](https://github.com/xinntao/BasicSR), [MPRNet](https://github.com/swz30/MPRNet)).\n\n--\u003e\n\nThe training code is at [KAIR](https://github.com/cszn/KAIR/blob/master/docs/README_SwinIR.md).\n\n## Testing (without preparing datasets)\nFor your convience, we provide some example datasets (~20Mb) in `/testsets`. \nIf you just want codes, downloading `models/network_swinir.py`, `utils/util_calculate_psnr_ssim.py` and `main_test_swinir.py` is enough.\nFollowing commands will download [pretrained models](https://github.com/JingyunLiang/SwinIR/releases) **automatically** and put them in `model_zoo/swinir`. \n**[All visual results of SwinIR can be downloaded here](https://github.com/JingyunLiang/SwinIR/releases)**. \n\nWe also provide an [online Colab demo for real-world image SR  \u003ca href=\"https://colab.research.google.com/gist/JingyunLiang/a5e3e54bc9ef8d7bf594f6fee8208533/swinir-demo-on-real-world-image-sr.ipynb\"\u003e\u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"google colab logo\"\u003e\u003c/a\u003e](https://colab.research.google.com/gist/JingyunLiang/a5e3e54bc9ef8d7bf594f6fee8208533/swinir-demo-on-real-world-image-sr.ipynb) for comparison with [the first practical degradation model BSRGAN (ICCV2021)  ![GitHub Stars](https://img.shields.io/github/stars/cszn/BSRGAN?style=social)](https://github.com/cszn/BSRGAN) and a recent model [RealESRGAN](https://github.com/xinntao/Real-ESRGAN). Try to test your own images on Colab!\n\nWe provide a PlayTorch demo [![PlayTorch Demo](https://github.com/facebookresearch/playtorch/blob/main/website/static/assets/playtorch_badge.svg)](https://playtorch.dev/snack/@playtorch/swinir/) for real-world image SR to showcase how to run the SwinIR model in mobile application built with React Native.\n\n```bash\n# 001 Classical Image Super-Resolution (middle size)\n# Note that --training_patch_size is just used to differentiate two different settings in Table 2 of the paper. Images are NOT tested patch by patch.\n# (setting1: when model is trained on DIV2K and with training_patch_size=48)\npython main_test_swinir.py --task classical_sr --scale 2 --training_patch_size 48 --model_path model_zoo/swinir/001_classicalSR_DIV2K_s48w8_SwinIR-M_x2.pth --folder_lq testsets/Set5/LR_bicubic/X2 --folder_gt testsets/Set5/HR\npython main_test_swinir.py --task classical_sr --scale 3 --training_patch_size 48 --model_path model_zoo/swinir/001_classicalSR_DIV2K_s48w8_SwinIR-M_x3.pth --folder_lq testsets/Set5/LR_bicubic/X3 --folder_gt testsets/Set5/HR\npython main_test_swinir.py --task classical_sr --scale 4 --training_patch_size 48 --model_path model_zoo/swinir/001_classicalSR_DIV2K_s48w8_SwinIR-M_x4.pth --folder_lq testsets/Set5/LR_bicubic/X4 --folder_gt testsets/Set5/HR\npython main_test_swinir.py --task classical_sr --scale 8 --training_patch_size 48 --model_path model_zoo/swinir/001_classicalSR_DIV2K_s48w8_SwinIR-M_x8.pth --folder_lq testsets/Set5/LR_bicubic/X8 --folder_gt testsets/Set5/HR\n\n# (setting2: when model is trained on DIV2K+Flickr2K and with training_patch_size=64)\npython main_test_swinir.py --task classical_sr --scale 2 --training_patch_size 64 --model_path model_zoo/swinir/001_classicalSR_DF2K_s64w8_SwinIR-M_x2.pth --folder_lq testsets/Set5/LR_bicubic/X2 --folder_gt testsets/Set5/HR\npython main_test_swinir.py --task classical_sr --scale 3 --training_patch_size 64 --model_path model_zoo/swinir/001_classicalSR_DF2K_s64w8_SwinIR-M_x3.pth --folder_lq testsets/Set5/LR_bicubic/X3 --folder_gt testsets/Set5/HR\npython main_test_swinir.py --task classical_sr --scale 4 --training_patch_size 64 --model_path model_zoo/swinir/001_classicalSR_DF2K_s64w8_SwinIR-M_x4.pth --folder_lq testsets/Set5/LR_bicubic/X4 --folder_gt testsets/Set5/HR\npython main_test_swinir.py --task classical_sr --scale 8 --training_patch_size 64 --model_path model_zoo/swinir/001_classicalSR_DF2K_s64w8_SwinIR-M_x8.pth --folder_lq testsets/Set5/LR_bicubic/X8 --folder_gt testsets/Set5/HR\n\n\n# 002 Lightweight Image Super-Resolution (small size)\npython main_test_swinir.py --task lightweight_sr --scale 2 --model_path model_zoo/swinir/002_lightweightSR_DIV2K_s64w8_SwinIR-S_x2.pth --folder_lq testsets/Set5/LR_bicubic/X2 --folder_gt testsets/Set5/HR\npython main_test_swinir.py --task lightweight_sr --scale 3 --model_path model_zoo/swinir/002_lightweightSR_DIV2K_s64w8_SwinIR-S_x3.pth --folder_lq testsets/Set5/LR_bicubic/X3 --folder_gt testsets/Set5/HR\npython main_test_swinir.py --task lightweight_sr --scale 4 --model_path model_zoo/swinir/002_lightweightSR_DIV2K_s64w8_SwinIR-S_x4.pth --folder_lq testsets/Set5/LR_bicubic/X4 --folder_gt testsets/Set5/HR\n\n\n# 003 Real-World Image Super-Resolution (use --tile 400 if you run out-of-memory)\n# (middle size)\npython main_test_swinir.py --task real_sr --scale 4 --model_path model_zoo/swinir/003_realSR_BSRGAN_DFO_s64w8_SwinIR-M_x4_GAN.pth --folder_lq testsets/RealSRSet+5images --tile\n\n# (larger size + trained on more datasets)\npython main_test_swinir.py --task real_sr --scale 4 --large_model --model_path model_zoo/swinir/003_realSR_BSRGAN_DFOWMFC_s64w8_SwinIR-L_x4_GAN.pth --folder_lq testsets/RealSRSet+5images\n\n\n# 004 Grayscale Image Deoising (middle size)\npython main_test_swinir.py --task gray_dn --noise 15 --model_path model_zoo/swinir/004_grayDN_DFWB_s128w8_SwinIR-M_noise15.pth --folder_gt testsets/Set12\npython main_test_swinir.py --task gray_dn --noise 25 --model_path model_zoo/swinir/004_grayDN_DFWB_s128w8_SwinIR-M_noise25.pth --folder_gt testsets/Set12\npython main_test_swinir.py --task gray_dn --noise 50 --model_path model_zoo/swinir/004_grayDN_DFWB_s128w8_SwinIR-M_noise50.pth --folder_gt testsets/Set12\n\n\n# 005 Color Image Deoising (middle size)\npython main_test_swinir.py --task color_dn --noise 15 --model_path model_zoo/swinir/005_colorDN_DFWB_s128w8_SwinIR-M_noise15.pth --folder_gt testsets/McMaster\npython main_test_swinir.py --task color_dn --noise 25 --model_path model_zoo/swinir/005_colorDN_DFWB_s128w8_SwinIR-M_noise25.pth --folder_gt testsets/McMaster\npython main_test_swinir.py --task color_dn --noise 50 --model_path model_zoo/swinir/005_colorDN_DFWB_s128w8_SwinIR-M_noise50.pth --folder_gt testsets/McMaster\n\n\n# 006 JPEG Compression Artifact Reduction (middle size, using window_size=7 because JPEG encoding uses 8x8 blocks)\n# grayscale\npython main_test_swinir.py --task jpeg_car --jpeg 10 --model_path model_zoo/swinir/006_CAR_DFWB_s126w7_SwinIR-M_jpeg10.pth --folder_gt testsets/classic5\npython main_test_swinir.py --task jpeg_car --jpeg 20 --model_path model_zoo/swinir/006_CAR_DFWB_s126w7_SwinIR-M_jpeg20.pth --folder_gt testsets/classic5\npython main_test_swinir.py --task jpeg_car --jpeg 30 --model_path model_zoo/swinir/006_CAR_DFWB_s126w7_SwinIR-M_jpeg30.pth --folder_gt testsets/classic5\npython main_test_swinir.py --task jpeg_car --jpeg 40 --model_path model_zoo/swinir/006_CAR_DFWB_s126w7_SwinIR-M_jpeg40.pth --folder_gt testsets/classic5\n\n# color\npython main_test_swinir.py --task color_jpeg_car --jpeg 10 --model_path model_zoo/swinir/006_colorCAR_DFWB_s126w7_SwinIR-M_jpeg10.pth --folder_gt testsets/LIVE1\npython main_test_swinir.py --task color_jpeg_car --jpeg 20 --model_path model_zoo/swinir/006_colorCAR_DFWB_s126w7_SwinIR-M_jpeg20.pth --folder_gt testsets/LIVE1\npython main_test_swinir.py --task color_jpeg_car --jpeg 30 --model_path model_zoo/swinir/006_colorCAR_DFWB_s126w7_SwinIR-M_jpeg30.pth --folder_gt testsets/LIVE1\npython main_test_swinir.py --task color_jpeg_car --jpeg 40 --model_path model_zoo/swinir/006_colorCAR_DFWB_s126w7_SwinIR-M_jpeg40.pth --folder_gt testsets/LIVE1\n\n```\n\n---\n\n## Results\nWe achieved state-of-the-art performance on classical/lightweight/real-world image SR, grayscale/color image denoising and JPEG compression artifact reduction. Detailed results can be found in the [paper](https://arxiv.org/abs/2108.10257). All visual results of SwinIR can be downloaded [here](https://github.com/JingyunLiang/SwinIR/releases). \n\n\u003cdetails\u003e\n\u003csummary\u003eClassical Image Super-Resolution (click me)\u003c/summary\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"900\" src=\"figs/classic_image_sr.png\"\u003e\n  \u003cimg width=\"900\" src=\"figs/classic_image_sr_visual.png\"\u003e\n\u003c/p\u003e\n  \n- More detailed comparison between SwinIR and a representative CNN-based model RCAN (classical image SR, X4)\n\n| Method             | Training Set    |  Training time  \u003cbr /\u003e (8GeForceRTX2080Ti \u003cbr /\u003e batch=32, iter=500k) |Y-PSNR/Y-SSIM \u003cbr /\u003e on Manga109 | Run time  \u003cbr /\u003e (1GeForceRTX2080Ti,\u003cbr /\u003e on 256x256 LR image)* |  #Params   | #FLOPs |  Testing memory |\n| :---      | :---:        |        :-----:         |     :---:      |     :---:      |     :---:      |   :---:      |  :---:      |\n| RCAN | DIV2K | 1.6 days | 31.22/0.9173 | 0.180s | 15.6M | 850.6G | 593.1M | \n| SwinIR | DIV2K | 1.8 days |31.67/0.9226 | 0.539s | 11.9M | 788.6G | 986.8M | \n\n\\* We re-test the runtime when the GPU is idle. We refer to the evluation code [here](https://github.com/cszn/KAIR/blob/master/main_challenge_sr.py).\n\n  \n- Results on DIV2K-validation (100 images)\n  \n|  Training Set | scale factor | PSNR (RGB) | PSNR (Y) | SSIM (RGB)  | SSIM (Y) |\n| :--- | :---: | :---:        |     :---:      | :---: | :---:        |\n|  DIV2K (800 images) | 2 | 35.25 | 36.77 | 0.9423 | 0.9500 |\n|  DIV2K+Flickr2K (2650 images) | 2 | 35.34 | 36.86 | 0.9430 |0.9507 |\n|  DIV2K (800 images) | 3 | 31.50 | 32.97 | 0.8832 |0.8965 |\n|  DIV2K+Flickr2K (2650 images) | 3 | 31.63 | 33.10 | 0.8854 |0.8985 |\n|  DIV2K (800 images) | 4 | 29.48 | 30.94 | 0.8311|0.8492 |\n|  DIV2K+Flickr2K (2650 images) | 4 | 29.63 | 31.08 | 0.8347|0.8523 |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eLightweight Image Super-Resolution\u003c/summary\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"900\" src=\"figs/lightweight_image_sr.png\"\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eReal-World Image Super-Resolution\u003c/summary\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"900\" src=\"figs/real_world_image_sr.png\"\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eGrayscale Image Deoising\u003c/summary\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"900\" src=\"figs/gray_image_denoising.png\"\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eColor Image Deoising\u003c/summary\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"900\" src=\"figs/color_image_denoising.png\"\u003e\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eJPEG Compression Artifact Reduction\u003c/summary\u003e\n\non grayscale images\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"900\" src=\"figs/jepg_compress_artfact_reduction.png\"\u003e\n\u003c/p\u003e\n\non color images\n\n| Training Set | quality factor | PSNR (RGB) | PSNR-B (RGB) | SSIM (RGB) |\n|:-------------|:--------------:|:----------:|:------------:|:----------:|\n| LIVE1        |       10       |   28.06    |    27.76     |   0.8089   |\n| LIVE1        |       20       |   30.45    |    29.97     |   0.8741   |\n| LIVE1        |       30       |   31.82    |    31.24     |   0.9018   |\n| LIVE1        |       40       |   32.75    |    32.12     |   0.9174   |\n\u003c/details\u003e\n\n\n\n## Citation\n    @article{liang2021swinir,\n      title={SwinIR: Image Restoration Using Swin Transformer},\n      author={Liang, Jingyun and Cao, Jiezhang and Sun, Guolei and Zhang, Kai and Van Gool, Luc and Timofte, Radu},\n      journal={arXiv preprint arXiv:2108.10257},\n      year={2021}\n    }\n\n\n## License and Acknowledgement\nThis project is released under the Apache 2.0 license. The codes are based on [Swin Transformer](https://github.com/microsoft/Swin-Transformer) and [KAIR](https://github.com/cszn/KAIR). Please also follow their licenses. Thanks for their awesome works.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjingyunliang%2Fswinir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjingyunliang%2Fswinir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjingyunliang%2Fswinir/lists"}