From 6cee870fcf38ae1f28cef80ad9421498938e819a Mon Sep 17 00:00:00 2001 From: LielinJiang <50691816+LielinJiang@users.noreply.github.com> Date: Sat, 6 Feb 2021 14:49:21 +0800 Subject: [PATCH] add realsr docs (#159) --- configs/realsr_bicubic_noise_x4_df2k.yaml | 6 +++--- configs/realsr_kernel_noise_x4_dped.yaml | 6 +++--- lsr2_preprocess.py => data/lsr2_preprocess.py | 0 data/realsr_preprocess/collect_noise.py | 3 ++- data/realsr_preprocess/create_bicubic_dataset.py | 6 ++++-- data/realsr_preprocess/paths.yml | 12 ++++++------ docs/en_US/tutorials/super_resolution.md | 10 ++++++++++ 7 files changed, 28 insertions(+), 15 deletions(-) rename lsr2_preprocess.py => data/lsr2_preprocess.py (100%) diff --git a/configs/realsr_bicubic_noise_x4_df2k.yaml b/configs/realsr_bicubic_noise_x4_df2k.yaml index d8b7423..95de7fb 100644 --- a/configs/realsr_bicubic_noise_x4_df2k.yaml +++ b/configs/realsr_bicubic_noise_x4_df2k.yaml @@ -34,8 +34,8 @@ model: dataset: train: name: SRDataset - gt_folder: data/realsr_preprocess/DF2K/generated/tdsr/HR_sub/ - lq_folder: data/realsr_preprocess/DF2K/generated/tdsr/LR_sub/ + gt_folder: data/DF2K/generated/tdsr/HR/ + lq_folder: data/DF2K/generated/tdsr/LR/ num_workers: 4 batch_size: 16 scale: 4 @@ -64,7 +64,7 @@ dataset: std: [255., 255., 255.] keys: [image, image] - name: SRNoise - noise_path: data/realsr_preprocess/DF2K/Corrupted_noise/ + noise_path: data/DF2K/Corrupted_noise/ size: 32 keys: [image] test: diff --git a/configs/realsr_kernel_noise_x4_dped.yaml b/configs/realsr_kernel_noise_x4_dped.yaml index 6aadc3f..9322d97 100644 --- a/configs/realsr_kernel_noise_x4_dped.yaml +++ b/configs/realsr_kernel_noise_x4_dped.yaml @@ -34,8 +34,8 @@ model: dataset: train: name: SRDataset - gt_folder: data/realsr_preprocess/DPED/generated/clean/train_tdsr/HR/ - lq_folder: data/realsr_preprocess/DPED/generated/clean/train_tdsr/LR/ + gt_folder: data/DPED/generated/clean/train_tdsr/HR/ + lq_folder: data/DPED/generated/clean/train_tdsr/LR/ num_workers: 4 batch_size: 16 scale: 4 @@ -64,7 +64,7 @@ dataset: std: [255., 255., 255.] keys: [image, image] - name: SRNoise - noise_path: data/realsr_preprocess/DPED/DPEDiphone_noise/ + noise_path: data/DPED/DPEDiphone_noise/ size: 32 keys: [image] test: diff --git a/lsr2_preprocess.py b/data/lsr2_preprocess.py similarity index 100% rename from lsr2_preprocess.py rename to data/lsr2_preprocess.py diff --git a/data/realsr_preprocess/collect_noise.py b/data/realsr_preprocess/collect_noise.py index 18a7c48..1520cba 100644 --- a/data/realsr_preprocess/collect_noise.py +++ b/data/realsr_preprocess/collect_noise.py @@ -27,7 +27,8 @@ parser.add_argument('--upscale_factor', opt = parser.parse_args() # define input and target directories -with open('./preprocess/paths.yml', 'r') as stream: +cur_path = os.path.abspath(os.path.dirname(__file__)) +with open(os.path.join(cur_path, './paths.yml'), 'r') as stream: PATHS = yaml.load(stream) diff --git a/data/realsr_preprocess/create_bicubic_dataset.py b/data/realsr_preprocess/create_bicubic_dataset.py index 085feb6..a9cb398 100644 --- a/data/realsr_preprocess/create_bicubic_dataset.py +++ b/data/realsr_preprocess/create_bicubic_dataset.py @@ -48,7 +48,8 @@ parser.add_argument('--upscale_factor', opt = parser.parse_args() # define input and target directories -with open('./paths.yml', 'r') as stream: +cur_path = os.path.abspath(os.path.dirname(__file__)) +with open(os.path.join(cur_path, './paths.yml'), 'r') as stream: PATHS = yaml.load(stream) if opt.dataset == 'df2k': @@ -82,7 +83,8 @@ else: tdsr_hr_dir = path_tdsr + 'HR' tdsr_lr_dir = path_tdsr + 'LR' -assert not os.path.exists(PATHS['datasets'][opt.dataset]) +assert not os.path.exists(tdsr_hr_dir) +assert not os.path.exists(tdsr_lr_dir) if not os.path.exists(tdsr_hr_dir): os.makedirs(tdsr_hr_dir) diff --git a/data/realsr_preprocess/paths.yml b/data/realsr_preprocess/paths.yml index 508ba30..ce20727 100644 --- a/data/realsr_preprocess/paths.yml +++ b/data/realsr_preprocess/paths.yml @@ -1,13 +1,13 @@ df2k: tdsr: - source: '/workspace/datasets/ntire20/Corrupted-tr-x' - target: '/workspace/datasets/ntire20/Corrupted-tr-y' + source: './data/ntire20/Corrupted-tr-x' + target: './data/ntire20/Corrupted-tr-y' valid: dped: clean: hr: - train: '/workspace/datasets/ntire20/DPEDiphone-tr-x' - valid: '/workspace/datasets/ntire20/DPEDiphone-va' + train: './data/ntire20/DPEDiphone-tr-x' + valid: './data/datasets/ntire20/DPEDiphone-va' datasets: - df2k: 'DF2K' - dped: 'DPED' + df2k: 'data/DF2K' + dped: 'data/DPED' diff --git a/docs/en_US/tutorials/super_resolution.md b/docs/en_US/tutorials/super_resolution.md index 25605cd..c5f0d1b 100644 --- a/docs/en_US/tutorials/super_resolution.md +++ b/docs/en_US/tutorials/super_resolution.md @@ -52,6 +52,16 @@ python data/process_div2k_data.py --data-root data/DIV2K ``` + Prepare dataset for realsr df2k model: + Download dataset from [NTIRE 2020 RWSR](https://competitions.codalab.org/competitions/22220#participate) and unzip it to your path. + Unzip Corrupted-tr-x.zip and Corrupted-tr-y.zip to ``PaddleGAN/data/ntire20`` directory. + + Run the following commands: + ``` + python ./data/realsr_preprocess/create_bicubic_dataset.py --dataset df2k --artifacts tdsr + + python ./data/realsr_preprocess/collect_noise.py --dataset df2k --artifacts tdsr + ``` ### 1.2.2 Train/Test -- GitLab