{"id":17349633,"url":"https://github.com/ZhendongWang6/Uformer","last_synced_at":"2025-02-26T02:32:03.115Z","repository":{"id":38341336,"uuid":"373423349","full_name":"ZhendongWang6/Uformer","owner":"ZhendongWang6","description":"[CVPR 2022] Official implementation of the paper \"Uformer: A General U-Shaped Transformer for Image Restoration\".","archived":false,"fork":false,"pushed_at":"2023-09-03T18:13:26.000Z","size":2175,"stargazers_count":653,"open_issues_count":36,"forks_count":100,"subscribers_count":12,"default_branch":"main","last_synced_at":"2023-10-20T23:59:45.555Z","etag":null,"topics":["deep-learning","image-deblurring","image-demoireing","image-denoising","image-deraining","image-restoration","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZhendongWang6.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}},"created_at":"2021-06-03T07:44:44.000Z","updated_at":"2023-10-21T13:41:35.769Z","dependencies_parsed_at":"2022-07-09T06:46:07.440Z","dependency_job_id":"f38dbe89-9512-425c-840a-ceafb831f350","html_url":"https://github.com/ZhendongWang6/Uformer","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhendongWang6%2FUformer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhendongWang6%2FUformer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhendongWang6%2FUformer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhendongWang6%2FUformer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZhendongWang6","download_url":"https://codeload.github.com/ZhendongWang6/Uformer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219843112,"owners_count":16556511,"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":["deep-learning","image-deblurring","image-demoireing","image-denoising","image-deraining","image-restoration","pytorch"],"created_at":"2024-10-15T16:56:24.486Z","updated_at":"2025-02-26T02:32:03.082Z","avatar_url":"https://github.com/ZhendongWang6.png","language":"Python","funding_links":[],"categories":["Table of Contents"],"sub_categories":["DETR变种"],"readme":"# Uformer: A General U-Shaped Transformer for Image Restoration (CVPR 2022)\n\u003cb\u003e\u003ca href='https://zhendongwang6.github.io'\u003eZhendong Wang\u003c/a\u003e, \u003ca href='https://vinthony.github.io'\u003eXiaodong Cun\u003c/a\u003e, \u003ca href='https://jianminbao.github.io/'\u003eJianmin Bao\u003c/a\u003e, \u003ca href='http://staff.ustc.edu.cn/~zhwg/'\u003eWengang Zhou\u003c/a\u003e, \u003ca href='http://people.ucas.ac.cn/~jzliu?language=en'\u003eJianzhuang Liu\u003c/a\u003e, \u003ca href='http://staff.ustc.edu.cn/~lihq/en/'\u003eHouqiang Li \u003c/a\u003e \u003c/b\u003e\n\n[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/uformer-a-general-u-shaped-transformer-for/deblurring-on-realblur-j-trained-on-gopro)](https://paperswithcode.com/sota/deblurring-on-realblur-j-trained-on-gopro?p=uformer-a-general-u-shaped-transformer-for) [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/uformer-a-general-u-shaped-transformer-for/deblurring-on-realblur-r-trained-on-gopro)](https://paperswithcode.com/sota/deblurring-on-realblur-r-trained-on-gopro?p=uformer-a-general-u-shaped-transformer-for)\t\n[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/uformer-a-general-u-shaped-transformer-for/image-denoising-on-dnd)](https://paperswithcode.com/sota/image-denoising-on-dnd?p=uformer-a-general-u-shaped-transformer-for) [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/uformer-a-general-u-shaped-transformer-for/image-denoising-on-sidd)](https://paperswithcode.com/sota/image-denoising-on-sidd?p=uformer-a-general-u-shaped-transformer-for)\n[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/uformer-a-general-u-shaped-transformer-for/deblurring-on-gopro)](https://paperswithcode.com/sota/deblurring-on-gopro?p=uformer-a-general-u-shaped-transformer-for) [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/uformer-a-general-u-shaped-transformer-for/deblurring-on-hide-trained-on-gopro)](https://paperswithcode.com/sota/deblurring-on-hide-trained-on-gopro?p=uformer-a-general-u-shaped-transformer-for)\n[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/uformer-a-general-u-shaped-transformer-for/image-defocus-deblurring-on-dpd)](https://paperswithcode.com/sota/image-defocus-deblurring-on-dpd?p=uformer-a-general-u-shaped-transformer-for)\n[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/uformer-a-general-u-shaped-transformer-for/image-enhancement-on-tip-2018)](https://paperswithcode.com/sota/image-enhancement-on-tip-2018?p=uformer-a-general-u-shaped-transformer-for)\n\nPaper link: [[Arxiv]](https://arxiv.org/abs/2106.03106) [[CVPR]](https://openaccess.thecvf.com/content/CVPR2022/papers/Wang_Uformer_A_General_U-Shaped_Transformer_for_Image_Restoration_CVPR_2022_paper.pdf)\n\n\n### Update:\n* **2024.10.24** Fix expired links.\n* **2022.07.06** Upload new codes and models for our Uformer. \n* **2022.04.09** Upload results of Uformer on denoising (SIDD, DND), motion deblurring (GoPro, HIDE, RealBlur-J/-R), and defocus deblurring (DPDD). \n* **2022.03.02** Uformer has been accepted by CVPR 2022! :fire:\n* **2021.11.30** Update Uformer in [Arxiv link](https://arxiv.org/abs/2106.03106). The new code, models and results will be uploaded.\n* **2021.10.28** Release the results of Uformer32 on SIDD and DND.\n* **2021.09.30** Release pre-trained Uformer16 for SIDD denoising.\n* **2021.08.19** Release a pre-trained model(Uformer32)! Add a script for FLOP/GMAC calculation.\n* **2021.07.29** Add a script for testing the pre-trained model on the arbitrary-resolution images.\n\n\u003chr\u003e\n\u003ci\u003eIn this paper, we present Uformer, an effective and efficient Transformer-based architecture, in which we build a hierarchical encoder-decoder network using the Transformer block for image restoration. Uformer has two core designs to make it suitable for this task. The first key element is a local-enhanced window Transformer block, where we use non-overlapping window-based self-attention to reduce the computational requirement and employ the depth-wise convolution in the feed-forward network to further improve its potential for capturing local context. The second key element is that we explore three skip-connection schemes to effectively deliver information from the encoder to the decoder. Powered by these two designs, Uformer enjoys a high capability for capturing useful dependencies for image restoration. Extensive experiments on several image restoration tasks demonstrate the superiority of Uformer, including image denoising, deraining, deblurring and demoireing. We expect that our work will encourage further research to explore Transformer-based architectures for low-level vision tasks.\u003c/i\u003e\n\n![Uformer](fig/Uformer.png)\n\n## Package dependencies\nThe project is built with PyTorch 1.9.0, Python3.7, CUDA11.1. For package dependencies, you can install them by:\n```bash\npip install -r requirements.txt\n```\n\n## Pretrained model\n- Uformer_B: [SIDD](https://mailustceducn-my.sharepoint.com/:u:/g/personal/zhendongwang_mail_ustc_edu_cn/Ea7hMP82A0xFlOKPlQnBJy0B9gVP-1MJL75mR4QKBMGc2w?e=iOz0zz) |\n[GoPro](https://mailustceducn-my.sharepoint.com/:u:/g/personal/zhendongwang_mail_ustc_edu_cn/EfCPoTSEKJRAshoE6EAC_3YB7oNkbLUX6AUgWSCwoJe0oA?e=jai90x)\n\n## Results from the pretrained model\n- Uformer_B: [SIDD](https://mailustceducn-my.sharepoint.com/:f:/g/personal/zhendongwang_mail_ustc_edu_cn/EtcRYRDGWhBIlQa3EYBp4FYBao7ZZT2dPc5k1Qe-CdPh3A?e=PjBMub) | [DND](https://mailustceducn-my.sharepoint.com/:f:/g/personal/zhendongwang_mail_ustc_edu_cn/Ekv3A5ic_4RChFa9XXquF_MB8M8tFd7spyHGJi_8obycnA?e=W7xeHe) | [GoPro](https://mailustceducn-my.sharepoint.com/:f:/g/personal/zhendongwang_mail_ustc_edu_cn/ElFalK0Qb8NHnyvhkSe1APgB5D0urGRMLnu2nBXJhtzdIw?e=D2XBhS) | [HIDE](https://mailustceducn-my.sharepoint.com/:f:/g/personal/zhendongwang_mail_ustc_edu_cn/Eh4p1_kZ95xIopXDNyhl-Q0B65xX6C3J_fL-TQDbgvofqQ?e=8766eT) | [RealBlur-J](https://mailustceducn-my.sharepoint.com/:f:/g/personal/zhendongwang_mail_ustc_edu_cn/EpHFC9FauEpHhJDsFruEmmQBJ4_ZZaMgjaO9SHmB_vocaA?e=3a4b8A) | [RealBlur-R](https://mailustceducn-my.sharepoint.com/:f:/g/personal/zhendongwang_mail_ustc_edu_cn/Eo2EC8rmkapNu9CxcYLwFpYBD8tX8pvfX_60jJIP8TGgGQ?e=yGbkQ8) | [DPDD](https://mailustceducn-my.sharepoint.com/:f:/g/personal/zhendongwang_mail_ustc_edu_cn/EvVAI84ZvlNChWsZA6QY4IkBc201zdTAs_g2Ufd5l0FgIQ?e=2DTlah)\n\n\n## Data preparation \n### Denoising\nFor training data of SIDD, you can download the SIDD-Medium dataset from the [official url](https://www.eecs.yorku.ca/~kamel/sidd/dataset.php).\nThen generate training patches for training by:\n```python\npython3 generate_patches_SIDD.py --src_dir ../SIDD_Medium_Srgb/Data --tar_dir ../datasets/denoising/sidd/train\n```\n\nFor evaluation on SIDD and DND, you can download data from [here](https://mailustceducn-my.sharepoint.com/:f:/g/personal/zhendongwang_mail_ustc_edu_cn/Ev832uKaw2JJhwROKqiXGfMBttyFko_zrDVzfSbFFDoi4Q?e=S3p5hQ).\n\n\n### Deblurring\nFor training on GoPro, and evaluation on GoPro, HIDE, RealBlur-J and RealBlur-R, you can download data from [here](https://mailustceducn-my.sharepoint.com/:f:/g/personal/zhendongwang_mail_ustc_edu_cn/Ev832uKaw2JJhwROKqiXGfMBttyFko_zrDVzfSbFFDoi4Q?e=S3p5hQ).\n\n\nThen put all the denoising data into `../datasets/denoising`, and all the deblurring data into `../datasets/deblurring`.\n\n## Training\n### Denoising\nTo train Uformer on SIDD, you can begin the training by:\n\n```sh\nsh script/train_denoise.sh\n```\n### Deblurring\nTo train Uformer on GoPro, you can begin the training by:\n\n```sh\nsh script/train_motiondeblur.sh\n```\n\n\n## Evaluation\nTo evaluate Uformer, you can run:\n\n```sh\nsh script/test.sh\n```\nFor evaluate on each dataset, you should uncomment corresponding line.\n\n## Computational Cost\n\nWe provide a simple script to calculate the flops by ourselves, a simple script has been added in `model.py`. You can change the configuration and run:\n\n```python\npython3 model.py\n```\n\n\u003e The manual calculation of GMacs in this repo differs slightly from the main paper, but they do not influence the conclusion. We will correct the paper later.\n\n\n## Citation\nIf you find this project useful in your research, please consider citing:\n\n```\n@InProceedings{Wang_2022_CVPR,\n    author    = {Wang, Zhendong and Cun, Xiaodong and Bao, Jianmin and Zhou, Wengang and Liu, Jianzhuang and Li, Houqiang},\n    title     = {Uformer: A General U-Shaped Transformer for Image Restoration},\n    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},\n    month     = {June},\n    year      = {2022},\n    pages     = {17683-17693}\n}\n```\n\n## Acknowledgement\n\nThis code borrows heavily from [MIRNet](https://github.com/swz30/MIRNet) and [SwinTransformer](https://github.com/microsoft/Swin-Transformer).\n\n\n## Contact\nPlease contact us if there is any question or suggestion(Zhendong Wang ZhendongWang6@outlook.com, Xiaodong Cun vinthony@gmail.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZhendongWang6%2FUformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FZhendongWang6%2FUformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZhendongWang6%2FUformer/lists"}