{"id":13679899,"url":"https://github.com/S-aiueo32/srntt-pytorch","last_synced_at":"2025-04-29T19:32:15.498Z","repository":{"id":37225029,"uuid":"221492320","full_name":"S-aiueo32/srntt-pytorch","owner":"S-aiueo32","description":"A PyTorch implementation of SRNTT, which is a novel RefSR method.","archived":false,"fork":false,"pushed_at":"2023-02-16T06:37:34.000Z","size":13968,"stargazers_count":109,"open_issues_count":18,"forks_count":24,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-11T22:35:42.845Z","etag":null,"topics":["paper-implementations","pytorch","reference-based","refsr","srntt","super-resolution"],"latest_commit_sha":null,"homepage":"","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/S-aiueo32.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}},"created_at":"2019-11-13T15:35:47.000Z","updated_at":"2024-10-23T06:54:40.000Z","dependencies_parsed_at":"2024-01-14T15:32:12.215Z","dependency_job_id":null,"html_url":"https://github.com/S-aiueo32/srntt-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/S-aiueo32%2Fsrntt-pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S-aiueo32%2Fsrntt-pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S-aiueo32%2Fsrntt-pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/S-aiueo32%2Fsrntt-pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/S-aiueo32","download_url":"https://codeload.github.com/S-aiueo32/srntt-pytorch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251569550,"owners_count":21610575,"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":["paper-implementations","pytorch","reference-based","refsr","srntt","super-resolution"],"created_at":"2024-08-02T13:01:10.823Z","updated_at":"2025-04-29T19:32:11.484Z","avatar_url":"https://github.com/S-aiueo32.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# srntt-pytorch\nA PyTorch implementation of SRNTT[1], which is a novel Reference-based Super-Resolution method proposed in CVPR 2019.\n\n## Requirements\n### Python\n```shell\n$ python --version\nPython 3.7.4\n```\n\n### Packages\nMainly used packages are below:\n```\n- torch\n- torchvision\n- kornia\n- scikit-learn etc., see more in Pipfile\n```\nThis Python environment is managed by `pipenv`, so you can create a virtual environmet like below:\n```shell\n$ pipenv install\n```\n\n### [WIP] Working with Docker 🐳\n#### Build Docker image\n```shell\n$ sudo docker build -t srntt-pytorch .\n```\n#### Run Docker container\n```shell\n$ sudo docker run --rm --runtime nvidia -it srntt-pytorch /bin/bash\n```\n\n## Training\n### Get started\n```shell\n$ sh scripts/train.sh\n```\nMore detailed descriptions are provided in the following sections.\n\n### Downloading data\nYou can get data through the following command, which is provided by the author.\n```shell\n$ python download_dataset.py --dataset_name DATASE_NAME\n```\nThe available dataset names are `{DIV2K, CUFED, CUFED5}`. `DIV2K` and `CUFED` datasets can be used as train data, and `CUFED5` can be used as test data.\nThe downloaded data will be placed in `./data` directory.\n\n### Downloading a pre-trained weight\nIn the training of SRNTT, the initial weights for content extractor is set as pre-trained SRGAN model. In this implementation, we exploit Modified-SRGAN (MSRGAN) provided by MMSR bacause it is thought as a reliable source. Let's download it as below!\n```shell\n$ python download_pretrained_model.py\n```\n\n### Offline texture swapping\nSRNTT requires HR-LR image pairs and the corresponding reference(Ref) images, moreover the swapped feature maps culculated from LR-Ref images.\nThe calculation is time-comsuming and has high comtational costs.\n\nIn general, the swapped feature maps of train data is culculated offline to speed up the training.\nThe offline calculation will be done by the following command.\n```shell\n$ python offline_texture_swapping.py --dataroot DATSET_NAME\n```\n\n### Training SRNTT\nAll of the preparation was done as above, so let's train the networks.\nWe recommend to use `--use_weights` option at all times (appeared in Eq. (6)).\n```shell\n$ python train.py --use_weights\n```\n\n## Testing\nYou can test on `CUFED5` dataset as below.\nIf you have not used `--use_weights` option in the training, you don't have to specify the option.\n```shell\n$ python test.py -w ./runs/your/pth/path --use_weights\n```\n\n## Online inference on any images\nNow, we support online inference on any images.\nThe input image you specify will be x4 downscaled by bicubic, and super-resolved with your ref image.\n```shell\n$ python online_inference.py -w ./runs/your/pth/path -i ./your/input/image -r ./your/ref/image --use_weights\n```\n\n## Pretrained models\nYou can get pretrained models from [here](https://drive.google.com/drive/folders/1yrIft2GXcDR-IW_uFLy69caVqEaByFDf?usp=sharing).\n\n\n## Results\n`HR/LR image` means GT/input image. `MSRGAN` is the result of MSRGAN from MMSR. `SR image (HR)` indicates super-resolved image with HR image itself, and `SR image (Lx)` indicates super-resolved one with a similar reference (left bottom) image.\n![comparison_002](./src/comparison_002.png)\n![comparison_065](./src/comparison_065.png)\n![comparison_078](./src/comparison_078.png)\n\nSee the other results and metrics [here](https://drive.google.com/drive/folders/1ZMmlJD4gHVYUCisRr785h_04zMDyTjC-?usp=sharing).\n\n## Reference\nThanks you for the following!\n### Papers\n1. Zhang, Zhifei, et al. \"Image Super-Resolution by Neural Texture Transfer.\" Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. 2019.\n### Implementations\n1. The original implementation (TF) - https://github.com/ZZUTK/SRNTT\n1. MMSR - https://github.com/open-mmlab/mmsr\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FS-aiueo32%2Fsrntt-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FS-aiueo32%2Fsrntt-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FS-aiueo32%2Fsrntt-pytorch/lists"}