Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support specifying scales in preprocessing div2k dataset #472

Merged
merged 10 commits into from
Aug 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Expand Up @@ -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.
Expand All @@ -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 = {}
Expand All @@ -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,
Expand Down Expand Up @@ -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='?',
Expand Down