Skip to content

Commit

Permalink
Support specifying scales in preprocessing div2k dataset (#472)
Browse files Browse the repository at this point in the history
* First commit!
Add a new scripts to generate training data pairs for blind super resolution

* Second commit!
made some modification

* Third commit
1.remove preprocess_div2k_dataset_bsr.py;
2.add a new argument into preprocess_div2k_dataset.py script to control
whether crop LR images;
3.modify corresponding README.md and README_zh-CN.md.

* Fourth Commit
Replace custom-degradation argument with scale

* Fifth Commit
Restore README.md and README_zh-CN.md

* Sixth Commit
Restore README.md and README_zh-CN.md

* Update README_zh-CN.md

* update annotations

* scale -> scales

Co-authored-by: lizz <lizz@sensetime.com>
  • Loading branch information
wileewang and innerlee authored Aug 12, 2021
1 parent 8345720 commit 7719dc0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tools/data/super-resolution/div2k/preprocess_div2k_dataset.py
Original file line number Diff line number Diff line change
@@ -22,6 +22,9 @@ def main_extract_subimages(args):
A higher value means a smaller size and longer compression time.
Use 0 for faster CPU decompression. Default: 3, same in cv2.
scales (list[int]): The downsampling factors corresponding to the
LR folders you want to process.
Default: [2, 3, 4].
input_folder (str): Path to the input folder.
save_folder (str): Path to save folder.
crop_size (int): Crop size.
@@ -31,14 +34,16 @@ def main_extract_subimages(args):
Usage:
For each folder, run this script.
Typically, there are four folders to be processed for DIV2K dataset.
By default, there are four folders to be processed for DIV2K dataset
according to scale factor list ([2,3,4])
DIV2K_train_HR
DIV2K_train_LR_bicubic/X2
DIV2K_train_LR_bicubic/X3
DIV2K_train_LR_bicubic/X4
After process, each sub_folder should have the same number of
subimages.
Remember to modify opt configurations according to your settings.
subimages. You can also specify scales by modifying the argument
'scales'. Remember to modify opt configurations according to your
settings.
"""

opt = {}
@@ -53,7 +58,7 @@ def main_extract_subimages(args):
opt['thresh_size'] = args.thresh_size
extract_subimages(opt)

for scale in [2, 3, 4]:
for scale in args.scales:
opt['input_folder'] = osp.join(args.data_root,
f'DIV2K_train_LR_bicubic/X{scale}')
opt['save_folder'] = osp.join(args.data_root,
@@ -344,6 +349,8 @@ def parse_args():
description='Prepare DIV2K dataset',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--data-root', help='dataset root')
parser.add_argument(
'--scales', nargs='*', default=[2, 3, 4], help='scale factor list')
parser.add_argument(
'--crop-size',
nargs='?',

0 comments on commit 7719dc0

Please sign in to comment.