From 7fcc11f25529f4e92e99ca10dc4845ae68d1702e Mon Sep 17 00:00:00 2001 From: Xintao Date: Fri, 23 Jul 2021 17:52:05 +0800 Subject: [PATCH] update file organization, fix bug: scale argument in RRDB --- .github/workflows/pylint.yml | 6 +++--- README.md | 5 +++++ data/__init__.py | 10 ++++++++++ inference_realesrgan.py | 4 +++- models/__init__.py | 10 ++++++++++ 5 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 data/__init__.py create mode 100644 models/__init__.py diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 7fe713b..1d8b501 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -1,4 +1,4 @@ -name: Python Lint +name: PyLint on: [push, pull_request] @@ -26,5 +26,5 @@ jobs: - name: Lint run: | flake8 . - isort --check-only --diff basicsr/ options/ scripts/ tests/ inference/ setup.py - yapf -r -d basicsr/ options/ scripts/ tests/ inference/ setup.py + isort --check-only --diff data/ models/ inference_realesrgan.py + yapf -r -d data/ models/ inference_realesrgan.py diff --git a/README.md b/README.md index 9817777..44dce3b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # Real-ESRGAN +[![download](https://img.shields.io/github/downloads/xinntao/Real-ESRGAN/total.svg)](https://github.com/xinntao/Real-ESRGAN/releases) +[![Open issue](https://isitmaintained.com/badge/open/xinntao/Real-ESRGAN.svg)](https://github.com/xinntao/Real-ESRGAN/issues) +[![LICENSE](https://img.shields.io/github/license/xinntao/Real-ESRGAN.svg)](https://github.com/xinntao/Real-ESRGAN/blob/master/LICENSE) +[![python lint](https://github.com/xinntao/Real-ESRGAN/actions/workflows/pylint.yml/badge.svg)](https://github.com/xinntao/Real-ESRGAN/blob/master/.github/workflows/pylint.yml) + [**Paper**](https://arxiv.org/abs/2107.10833) ### :book: Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data diff --git a/data/__init__.py b/data/__init__.py new file mode 100644 index 0000000..3b8afa6 --- /dev/null +++ b/data/__init__.py @@ -0,0 +1,10 @@ +import importlib +from basicsr.utils import scandir +from os import path as osp + +# automatically scan and import dataset modules for registry +# scan all the files that end with '_dataset.py' under the data folder +data_folder = osp.dirname(osp.abspath(__file__)) +dataset_filenames = [osp.splitext(osp.basename(v))[0] for v in scandir(data_folder) if v.endswith('_dataset.py')] +# import all the dataset modules +_dataset_modules = [importlib.import_module(f'data.{file_name}') for file_name in dataset_filenames] diff --git a/inference_realesrgan.py b/inference_realesrgan.py index 2bee50d..45b1714 100644 --- a/inference_realesrgan.py +++ b/inference_realesrgan.py @@ -17,7 +17,9 @@ def main(): device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') # set up model - model = RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=args.scale) + # FIXME: currenly RRDBNet in BasicSR does not support scale argument. Will update later + # model = RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=args.scale) + model = RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32) loadnet = torch.load(args.model_path) model.load_state_dict(loadnet['params_ema'], strict=True) model.eval() diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 0000000..a7ce9a2 --- /dev/null +++ b/models/__init__.py @@ -0,0 +1,10 @@ +import importlib +from basicsr.utils import scandir +from os import path as osp + +# automatically scan and import model modules for registry +# scan all the files that end with '_model.py' under the model folder +model_folder = osp.dirname(osp.abspath(__file__)) +model_filenames = [osp.splitext(osp.basename(v))[0] for v in scandir(model_folder) if v.endswith('_model.py')] +# import all the model modules +_model_modules = [importlib.import_module(f'models.{file_name}') for file_name in model_filenames]