{"id":18613984,"url":"https://github.com/jingyunliang/fkp","last_synced_at":"2025-08-01T07:15:44.705Z","repository":{"id":49351690,"uuid":"258586807","full_name":"JingyunLiang/FKP","owner":"JingyunLiang","description":"Official PyTorch code for Flow-based Kernel Prior with Application to Blind Super-Resolution (FKP, CVPR2021)","archived":false,"fork":false,"pushed_at":"2021-09-19T07:55:01.000Z","size":6821,"stargazers_count":148,"open_issues_count":6,"forks_count":21,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-25T06:51:10.692Z","etag":null,"topics":["blind-sr","blind-super-resolution","cvpr2021","image-sr","image-super-resolution","kernel-estimation","super-resolution"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2103.15977","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}},"created_at":"2020-04-24T18:05:59.000Z","updated_at":"2024-07-14T14:35:54.000Z","dependencies_parsed_at":"2022-09-01T19:10:30.941Z","dependency_job_id":null,"html_url":"https://github.com/JingyunLiang/FKP","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingyunLiang%2FFKP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingyunLiang%2FFKP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingyunLiang%2FFKP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingyunLiang%2FFKP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JingyunLiang","download_url":"https://codeload.github.com/JingyunLiang/FKP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248316523,"owners_count":21083460,"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":["blind-sr","blind-super-resolution","cvpr2021","image-sr","image-super-resolution","kernel-estimation","super-resolution"],"created_at":"2024-11-07T03:24:35.542Z","updated_at":"2025-04-10T23:32:12.505Z","avatar_url":"https://github.com/JingyunLiang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Flow-based Kernel Prior with Application to Blind Super-Resolution (FKP), CVPR2021\n\nThis repository is the official PyTorch implementation of Flow-based Kernel Prior with Application to Blind Super-Resolution \n([arxiv](https://arxiv.org/pdf/2103.15977.pdf), [supp](https://github.com/JingyunLiang/FKP/releases)).\n\n:rocket:  :rocket:  :rocket: **News**: \n - Aug. 18, 2021: See our recent work for [blind SR: Mutual Affine Network for Spatially Variant Kernel Estimation in Blind Image Super-Resolution (MANet), ICCV2021](https://github.com/JingyunLiang/MANet)\n - Aug. 18, 2021: See our recent work for [flow-based generative modelling of image SR: Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow), ICCV2021](https://github.com/JingyunLiang/HCFlow)\n - Aug. 18, 2021: See our recent work for [real-world image SR: Designing a Practical Degradation Model for Deep Blind Image Super-Resolution (BSRGAN), ICCV2021](https://github.com/cszn/BSRGAN)\n \n ---\n\n\u003e Kernel estimation is generally one of the key problems for blind image super-resolution (SR). Recently, Double-DIP proposes to model the kernel via a network architecture prior, while KernelGAN employs the deep linear network and several regularization losses to constrain the kernel space. However, they fail to fully exploit the general SR kernel assumption that anisotropic Gaussian kernels are sufficient for image SR. To address this issue, this paper proposes a normalizing flow-based kernel prior (FKP) for kernel modeling. By learning an invertible mapping between the anisotropic Gaussian kernel distribution and a tractable latent distribution, FKP can be easily used to replace the kernel modeling modules of Double-DIP and KernelGAN. Specifically, FKP optimizes the kernel in the latent space rather than the network parameter space, which allows it to generate reasonable kernel initialization, traverse the learned kernel manifold and improve the optimization stability. Extensive experiments on synthetic and real-world images demonstrate that the proposed FKP can significantly improve the kernel estimation accuracy with less parameters, runtime and memory usage, leading to state-of-the-art blind SR results.\n\u003e\u003cp align=\"center\"\u003e\n  \u003e \u003cimg height=\"120\" src=\"./data/illustrations/FKP.png\"\u003e\u003cimg height=\"120\" src=\"./data/illustrations/DIPFKP.png\"\u003e\u003cimg height=\"120\" src=\"./data/illustrations/KernelGANFKP.png\"\u003e\n\u003c/p\u003e\n\n## Requirements\n- Python 3.6, PyTorch \u003e= 1.6 \n- Requirements: opencv-python, tqdm\n- Platforms: Ubuntu 16.04, cuda-10.0 \u0026 cuDNN v-7.5\n\n\n## Quick Run\nTo run the code without preparing data, run this command:\n```bash\ncd DIPFKP\npython main.py --SR --sf 4 --dataset Test\n```\n\n---\n\n## Data Preparation\nTo prepare testing data, please organize images as `data/datasets/DIV2K/HR/0801.png`, and run this command:\n```bash\ncd data\npython prepare_dataset.py --model DIPFKP --sf 2 --dataset Set5\npython prepare_dataset.py --model KernelGANFKP --sf 2 --dataset DIV2K\n```\nCommonly used datasets can be downloaded [here](https://github.com/xinntao/BasicSR/blob/master/docs/DatasetPreparation.md#common-image-sr-datasets). Note that KernelGAN/KernelGAN-FKP use analytic X4 kernel based on X2, and do not support X3.\n\n## FKP\n\nTo train FKP, run this command:\n\n```bash\ncd FKP\npython main.py --train --sf 2\n```\nPretrained FKP and [USRNet](https://github.com/cszn/KAIR) models are already provided in `data/pretrained_models`.\n\n\n## DIP-FKP\n\nTo test DIP-FKP (no training phase), run this command:\n\n```bash\ncd DIPFKP\npython main.py --SR --sf 2 --dataset Set5\n```\n\n\n## KernelGAN-FKP\n\nTo test KernelGAN-FKP (no training phase), run this command:\n\n```bash\ncd KernelGANFKP\npython main.py --SR --sf 2 --dataset DIV2K\n```\n\n## Results\nPlease refer to the [paper](https://arxiv.org/pdf/2103.15977.pdf) and [supplementary](https://github.com/JingyunLiang/FKP/releases) for results. Since both DIP-FKP and KernelGAn-FKP are randomly intialized, different runs may get slightly different results. The reported results are averages of 5 runs.\n\n\n\n## Citation\n```\n@article{liang21fkp,\n  title={Flow-based Kernel Prior with Application to Blind Super-Resolution},\n  author={Liang, Jingyun and Zhang, Kai and Gu, Shuhang and Van Gool, Luc and Timofte, Radu},\n  journal={arXiv preprint arXiv:2103.15977},\n  year={2021}\n}\n```\n\n\n## License \u0026 Acknowledgement\n\nThis project is released under the Apache 2.0 license. The codes are based on [normalizing_flows](https://github.com/kamenbliznashki/normalizing_flows), [DIP](https://github.com/DmitryUlyanov/deep-image-prior), [KernelGAN](https://github.com/sefibk/KernelGAN) and [USRNet](https://github.com/cszn/KAIR). Please also follow their licenses. Thanks for their great works.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjingyunliang%2Ffkp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjingyunliang%2Ffkp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjingyunliang%2Ffkp/lists"}