{"id":24316214,"url":"https://github.com/Lornatang/SRGAN-PyTorch","last_synced_at":"2025-09-26T23:31:16.820Z","repository":{"id":37449644,"uuid":"256751193","full_name":"Lornatang/SRGAN-PyTorch","owner":"Lornatang","description":"A simple and complete implementation of super-resolution paper.","archived":false,"fork":false,"pushed_at":"2024-06-25T02:02:07.000Z","size":2974,"stargazers_count":396,"open_issues_count":4,"forks_count":104,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-06-25T03:23:38.888Z","etag":null,"topics":["aritificial-intelligence","gan","pytorch","resolution","srgan-pytorch"],"latest_commit_sha":null,"homepage":null,"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/Lornatang.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":"2020-04-18T12:43:29.000Z","updated_at":"2024-06-25T03:23:40.154Z","dependencies_parsed_at":"2024-04-08T04:43:44.804Z","dependency_job_id":null,"html_url":"https://github.com/Lornatang/SRGAN-PyTorch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lornatang%2FSRGAN-PyTorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lornatang%2FSRGAN-PyTorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lornatang%2FSRGAN-PyTorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lornatang%2FSRGAN-PyTorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lornatang","download_url":"https://codeload.github.com/Lornatang/SRGAN-PyTorch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234360836,"owners_count":18819962,"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":["aritificial-intelligence","gan","pytorch","resolution","srgan-pytorch"],"created_at":"2025-01-17T12:19:55.816Z","updated_at":"2025-09-26T23:31:16.422Z","avatar_url":"https://github.com/Lornatang.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# SRGAN-PyTorch\n\n## Overview\n\nThis repository contains an op-for-op PyTorch reimplementation\nof [Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network](https://arxiv.org/abs/1609.04802v5).\n\n## Table of contents\n\n- [SRGAN-PyTorch](#srgan-pytorch)\n    - [Overview](#overview)\n    - [Table of contents](#table-of-contents)\n    - [Download weights](#download-weights)\n    - [Download datasets](#download-datasets)\n    - [How Test and Train](#how-test-and-train)\n        - [Test SRGAN_x4](#test-srganx4)\n        - [Train srresnet_x4](#train-srresnetx4)\n        - [Resume train srresnet_x4](#resume-train-srresnetx4)\n        - [Train srgan_x4](#train-srganx4)\n        - [Resume train srgan_x4](#resume-train-srganx4)\n    - [Result](#result)\n    - [Contributing](#contributing)\n    - [Credit](#credit)\n        - [Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network](#photo-realistic-single-image-super-resolution-using-a-generative-adversarial-network)\n\n## Download weights\n\nDownload all available model weights.\n\n```shell\n# Download `SRGAN_x4-SRGAN_ImageNet.pth.tar` weights to `./results/pretrained_models`\n$ bash ./scripts/download_weights.sh SRGAN_x4-SRGAN_ImageNet\n# Download `SRResNet_x4-SRGAN_ImageNet.pth.tar` weights to `./results/pretrained_models`\n$ bash ./scripts/download_weights.sh SRResNet_x4-SRGAN_ImageNet\n# Download `DiscriminatorForVGG_x4-SRGAN_ImageNet.pth.tar` weights to `./results/pretrained_models`\n$ bash ./scripts/download_weights.sh DiscriminatorForVGG_x4-SRGAN_ImageNet\n```\n\n## Download datasets\n\nThese train images are randomly selected from the verification part of the ImageNet2012 classification dataset.\n\n```shell\n$ bash ./scripts/download_datasets.sh SRGAN_ImageNet\n```\n\nIt is convenient to download some commonly used test data sets here.\n\n```shell\n$ bash ./scripts/download_datasets.sh Set5\n```\n\n## How Test and Train\n\nBoth training and testing only need to modify yaml file.\n\nSet5 is used as the test benchmark in the project, and you can modify it by yourself.\n\nIf you need to test the effect of the model, download the test dataset.\n\n```shell\n$ bash ./scripts/download_datasets.sh Set5\n```\n\n### Test srgan_x4\n\n```shell\n$ python3 test.py --config_path ./configs/test/SRGAN_x4-SRGAN_ImageNet-Set5.yaml\n```\n\n### Test srresnet_x4\n\n```shell\n$ python3 test.py --config_path ./configs/test/SRResNet_x4-SRGAN_ImageNet-Set5.yaml\n```\n\n### Train srresnet_x4\n\nFirst, the dataset image is split into several small images to reduce IO and keep the batch image size uniform.\n\n```shell\n$ python3 ./scripts/split_images.py\n```\n\nThen, run the following commands to train the model\n\n```shell\n$ python3 train_net.py --config_path ./configs/train/SRResNet_x4-SRGAN_ImageNet.yaml\n```\n\n### Resume train srresnet_x4\n\nModify the `./configs/train/SRResNet_x4-SRGAN_ImageNet.yaml` file.\n\n- line 33: `RESUMED_G_MODEL` change to `./samples/SRResNet_x4-SRGAN_ImageNet/g_epoch_xxx.pth.tar`.\n\n```shell\n$ python3 train_net.py --config_path ./configs/train/SRResNet_x4-SRGAN_ImageNet.yaml\n```\n\n### Train srgan_x4\n\n```shell\n$ python3 train_gan.py --config_path ./configs/train/SRGAN_x4-SRGAN_ImageNet.yaml\n```\n\n### Resume train srgan_x4\n\nModify the `./configs/train/SRGAN_x4-SRGAN_ImageNet.yaml` file.\n\n- line 38: `PRETRAINED_G_MODEL` change to `./results/SRResNet_x4-SRGAN_ImageNet/g_last.pth.tar`.\n- line 40: `RESUMED_G_MODEL` change to `./samples/SRGAN_x4-SRGAN_ImageNet/g_epoch_xxx.pth.tar`.\n- line 41: `RESUMED_D_MODEL` change to `./samples/SRGAN_x4-SRGAN_ImageNet/d_epoch_xxx.pth.tar`.\n\n```shell\n$ python3 train_gan.py --config_path ./configs/train/SRGAN_x4-SRGAN_ImageNet.yaml\n```\n\n## Result\n\nSource of original paper results: [https://arxiv.org/pdf/1609.04802v5.pdf](https://arxiv.org/pdf/1609.04802v5.pdf)\n\nIn the following table, the psnr value in `()` indicates the result of the project, and `-` indicates no test.\n\n| Set5 | Scale |      SRResNet      |       SRGAN        |\n|:----:|:-----:|:------------------:|:------------------:|\n| PSNR |   4   |  32.05(**32.16**)  |  29.40(**30.67**)  |\n| SSIM |   4   | 0.9019(**0.8938**) | 0.8472(**0.8627**) |\n\n| Set14 | Scale |      SRResNet      |       SRGAN        |\n|:-----:|:-----:|:------------------:|:------------------:|\n| PSNR  |   4   |  28.49(**28.57**)  |  26.02(**27.12**)  |\n| SSIM  |   4   | 0.8184(**0.7815**) | 0.7397(**0.7321**) |\n\n| BSD100 | Scale |      SRResNet      |       SRGAN        |\n|:------:|:-----:|:------------------:|:------------------:|\n|  PSNR  |   4   |  27.58(**27.56**)  |  25.16(**26.22**)  |\n|  SSIM  |   4   | 0.7620(**0.7367**) | 0.6688(**0.6867**) |\n\n```bash\n# If you do not train the model yourself, you can download the model weights and test them.\n$ bash ./scripts/download_weights.sh SRGAN_x4-SRGAN_ImageNet\n$ python3 ./inference.py\n```\n\nInput:\n\n\u003cspan align=\"center\"\u003e\u003cimg width=\"240\" height=\"360\" src=\"figure/comic.png\"/\u003e\u003c/span\u003e\n\nOutput:\n\n\u003cspan align=\"center\"\u003e\u003cimg width=\"240\" height=\"360\" src=\"figure/sr_comic.png\"/\u003e\u003c/span\u003e\n\n```text\nBuild `srresnet_x4` model successfully.\nLoad `srresnet_x4` model weights `SRGAN-PyTorch/results/pretrained_models/SRGAN_x4-SRGAN_ImageNet.pth.tar` successfully.\nSR image save to `./figure/sr_comic.png`\n```\n\n## Contributing\n\nIf you find a bug, create a GitHub issue, or even better, submit a pull request. Similarly, if you have questions, simply post them as GitHub issues.\n\nI look forward to seeing what the community does with these models!\n\n## Credit\n\n### Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network\n\n_Christian Ledig, Lucas Theis, Ferenc Huszar, Jose Caballero, Andrew Cunningham, Alejandro Acosta, Andrew Aitken, Alykhan Tejani, Johannes Totz, Zehan\nWang, Wenzhe Shi_ \u003cbr\u003e\n\n**Abstract** \u003cbr\u003e\nDespite the breakthroughs in accuracy and speed of single image super-resolution using faster and deeper convolutional neural networks, one central\nproblem remains largely unsolved: how do we recover the finer texture details when we super-resolve at large upscaling factors? The behavior of\noptimization-based super-resolution methods is principally driven by the choice of the objective function. Recent work has largely focused on\nminimizing the mean squared reconstruction error. The resulting estimates have high peak signal-to-noise ratios, but they are often lacking\nhigh-frequency details and are perceptually unsatisfying in the sense that they fail to match the fidelity expected at the higher resolution. In this\npaper, we present SRGAN, a generative adversarial network (GAN) for image super-resolution (SR). To our knowledge, it is the first framework capable\nof inferring photo-realistic natural images for 4x upscaling factors. To achieve this, we propose a perceptual loss function which consists of an\nadversarial loss and a content loss. The adversarial loss pushes our solution to the natural image manifold using a discriminator network that is\ntrained to differentiate between the super-resolved images and original photo-realistic images. In addition, we use a content loss motivated by\nperceptual similarity instead of similarity in pixel space. Our deep residual network is able to recover photo-realistic textures from heavily\ndownsampled images on public benchmarks. An extensive mean-opinion-score (MOS) test shows hugely significant gains in perceptual quality using SRGAN.\nThe MOS scores obtained with SRGAN are closer to those of the original high-resolution images than to those obtained with any state-of-the-art method.\n\n[[Paper]](https://arxiv.org/pdf/1609.04802v5.pdf)\n\n```bibtex\n@InProceedings{srgan,\n    author = {Christian Ledig, Lucas Theis, Ferenc Huszar, Jose Caballero, Andrew Cunningham, Alejandro Acosta, Andrew Aitken, Alykhan Tejani, Johannes Totz, Zehan Wang, Wenzhe Shi},\n    title = {Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network},\n    booktitle = {arXiv},\n    year = {2016}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLornatang%2FSRGAN-PyTorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLornatang%2FSRGAN-PyTorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLornatang%2FSRGAN-PyTorch/lists"}