{"id":16548672,"url":"https://github.com/george-gca/sr-pytorch-lightning","last_synced_at":"2025-07-20T01:05:54.584Z","repository":{"id":150308014,"uuid":"540166351","full_name":"george-gca/sr-pytorch-lightning","owner":"george-gca","description":"Super-Resolution models implemented in PyTorch Lightning","archived":false,"fork":false,"pushed_at":"2023-08-04T21:34:17.000Z","size":89,"stargazers_count":19,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T21:41:38.839Z","etag":null,"topics":["artificial-intelligence","deep-learning","edsr","neural-networks","python","pytorch","pytorch-lightning","rcan","rdn","srcnn","super-resolution","wdsr"],"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/george-gca.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":"2022-09-22T20:54:29.000Z","updated_at":"2025-03-24T17:49:44.000Z","dependencies_parsed_at":"2025-02-13T15:44:37.518Z","dependency_job_id":null,"html_url":"https://github.com/george-gca/sr-pytorch-lightning","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/george-gca/sr-pytorch-lightning","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/george-gca%2Fsr-pytorch-lightning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/george-gca%2Fsr-pytorch-lightning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/george-gca%2Fsr-pytorch-lightning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/george-gca%2Fsr-pytorch-lightning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/george-gca","download_url":"https://codeload.github.com/george-gca/sr-pytorch-lightning/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/george-gca%2Fsr-pytorch-lightning/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266052533,"owners_count":23869475,"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":["artificial-intelligence","deep-learning","edsr","neural-networks","python","pytorch","pytorch-lightning","rcan","rdn","srcnn","super-resolution","wdsr"],"created_at":"2024-10-11T19:26:42.087Z","updated_at":"2025-07-20T01:05:54.573Z","avatar_url":"https://github.com/george-gca.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp\u003e\n  \u003ca href=\"https://www.gnu.org/software/bash/manual/bash.html\"\u003e\u003cimg alt=\"Shell Script\" src=\"https://img.shields.io/badge/-Shell Script-2C3840?style=flat-square\u0026logo=gnu-bash\u0026logoColor=white\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.python.org/\"\u003e\u003cimg alt=\"Python 3\" src=\"https://img.shields.io/badge/-Python-2b5b84?style=flat-square\u0026logo=python\u0026logoColor=white\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://pytorch.org/\"\u003e\u003cimg alt=\"PyTorch\" src=\"https://img.shields.io/badge/-PyTorch-ee4c2c?style=flat-square\u0026logo=pytorch\u0026logoColor=white\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://lightning.ai/\"\u003e\u003cimg alt=\"Lightning\" src=\"https://img.shields.io/badge/-Lightning-792de4?style=flat-square\u0026logo=lightning\u0026logoColor=white\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.docker.com/\"\u003e\u003cimg alt=\"Docker\" src=\"https://img.shields.io/badge/-Docker-0073ec?style=flat-square\u0026logo=docker\u0026logoColor=white\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.comet.com/\"\u003e\u003cimg alt=\"Comet\" src=\"https://custom-icon-badges.herokuapp.com/badge/Comet-262c3e?style=flat-square\u0026logo=logo_comet_ml\u0026logoColor=white\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# sr-pytorch-lightning\n\n## Introduction\n\nSuper resolution algorithms implemented with [Pytorch Lightning](https://github.com/PyTorchLightning/pytorch-lightning). Based on [code by So Uchida](https://github.com/S-aiueo32/sr-pytorch-lightning).\n\nCurrently supports the following models:\n\n- [DDBPN](https://openaccess.thecvf.com/content_cvpr_2018/papers/Haris_Deep_Back-Projection_Networks_CVPR_2018_paper.pdf)\n- [EDSR](https://openaccess.thecvf.com/content_cvpr_2017_workshops/w12/papers/Lim_Enhanced_Deep_Residual_CVPR_2017_paper.pdf)\n- [RCAN](https://openaccess.thecvf.com/content_ECCV_2018/papers/Yulun_Zhang_Image_Super-Resolution_Using_ECCV_2018_paper.pdf)\n- [RDN](https://openaccess.thecvf.com/content_cvpr_2018/papers/Zhang_Residual_Dense_Network_CVPR_2018_paper.pdf)\n- [SRCNN](https://ieeexplore.ieee.org/document/7115171?arnumber=7115171) - [arXiv](https://arxiv.org/pdf/1501.00092.pdf)\n- [SRGAN](https://openaccess.thecvf.com/content_cvpr_2017/papers/Ledig_Photo-Realistic_Single_Image_CVPR_2017_paper.pdf)\n- [SRResNet](https://openaccess.thecvf.com/content_cvpr_2017/papers/Ledig_Photo-Realistic_Single_Image_CVPR_2017_paper.pdf)\n- [WDSR](https://bmvc2019.org/wp-content/uploads/papers/0288-paper.pdf)\n\n## Requirements\n\n- [docker](https://docs.docker.com/engine/install/)\n- make\n  - install support for Makefile on Ubuntu-based distros using `sudo apt install build-essential`\n\n## Usage\n\nI decided to split the logic of dealing with `docker` (contained in [Makefile](Makefile)) from running the `python` code itself (contained in [start_here.sh](start_here.sh)). Since I run my code in a remote machine, I use `gnu screen` to keep the code running even if my connection fails.\n\nIn [Makefile](Makefile) there is a `environment variables` section, where a few variables might be set. More specifically, `DATASETS_PATH` must point to the root folder of your super resolution datasets.\n\nIn [start_here.sh](start_here.sh) a few variables might be set in the `variables` region. Default values have been set to allow easy experimentation.\n\n### Creating docker image\n\n```bash\nmake\n```\n\nIf you want to use the specific versions I used during my last experiments, check the [pytorch_1.11](https://github.com/george-gca/sr-pytorch-lightning/tree/pytorch_1.11) branch. To build the docker image using the specific versions that I used, simply run:\n\n```bash\nmake DOCKERFILE=Dockerfile_fixed_versions\n```\n\n### Testing docker image\n\n```bash\nmake test\n```\n\nThis should print information about all available GPUs, like this:\n\n```\nFound 2 devices:\n        _CudaDeviceProperties(name='NVIDIA Quadro RTX 8000', major=7, minor=5, total_memory=48601MB, multi_processor_count=72)\n        _CudaDeviceProperties(name='NVIDIA Quadro RTX 8000', major=7, minor=5, total_memory=48601MB, multi_processor_count=72)\n```\n\n### Training model\n\nIf you haven't configured the [telegram bot](#finished-experiment-telegram-notification) to notify when running is over, or don't want to use it, simply remove the line\n\n```bash\n$(TELEGRAM_BOT_MOUNT_STRING) \\\n```\n\nfrom the `make run` command on the [Makefile](Makefile), and also comment the line\n\n```bash\nsend_telegram_msg=1\n```\n\nin [start_here.sh](start_here.sh).\n\nThen, to train the models, simply call\n\n```bash\nmake run\n```\n\nBy default, it will run the file [start_here.sh](start_here.sh).\n\nIf you want to run another command inside the docker container, just change the default value for the `RUN_STRING` variable.\n\n```bash\nmake RUN_STRING=\"ipython3\" run\n```\n\n## Creating your own model\n\nTo create your own model, create a new file inside `models/` and create a class that inherits from [SRModel](models/srmodel.py). Your class should implement the `forward` method. Then, add your model to [\\_\\_init\\_\\_.py](models/__init__.py). The model will be automatically available as a `model` parameter option in [train.py](train.py) or [test.py](test.py).\n\nSome good starting points to create your own model are the [SRCNN](models/srcnn.py) and [EDSR](models/edsr.py) models.\n\n## Using Comet\n\nIf you want to use [Comet](https://www.comet.ml/) to log your experiments data, just create a file named `.comet.config` in the root folder here, and add the following lines:\n\n```config\n[comet]\napi_key=YOUR_API_KEY\n```\n\nMore configuration variables can be found [here](https://www.comet.ml/docs/python-sdk/advanced/#comet-configuration-variables).\n\nMost of the things that I found useful to log (metrics, codes, log, image results) are already being logged. Check [train.py](train.py) and [srmodel.py](models/srmodel.py) for more details. All these loggings are done by the [comet logger](https://pytorch-lightning.readthedocs.io/en/stable/api/lightning.pytorch.loggers.comet.html) already available from pytorch lightning. An example of these experiments logged in Comet can be found [here](https://www.comet.ml/george-gca/super-resolution-experiments).\n\n## Finished experiment Telegram notification\n\nSince the experiments can run for a while, I decided to use a telegram bot to notify me when experiments are done (or when there is an error). For this, I use the [telegram-send](https://github.com/rahiel/telegram-send) python package. I recommend you to install it in your machine and configure it properly.\n\nTo do this, simply use:\n\n```bash\npip3 install telegram-send\ntelegram-send --configure\n```\n\nThen, simply copy the configuration file created under `~/.config/telegram-send.conf` to another directory to make it easier to mount on the docker image. This can be configured in the source part of the `TELEGRAM_BOT_MOUNT_STRING` variable (by default is set to `$(HOME)/Docker/telegram_bot_config`) in the [Makefile](Makefile).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorge-gca%2Fsr-pytorch-lightning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeorge-gca%2Fsr-pytorch-lightning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorge-gca%2Fsr-pytorch-lightning/lists"}