Skip to content

Commit 7719dc0

Browse files
wileewanginnerlee
andauthored
Support specifying scales in preprocessing div2k dataset (open-mmlab#472)
* 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>
1 parent 8345720 commit 7719dc0

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

tools/data/super-resolution/div2k/preprocess_div2k_dataset.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ def main_extract_subimages(args):
2222
A higher value means a smaller size and longer compression time.
2323
Use 0 for faster CPU decompression. Default: 3, same in cv2.
2424
25+
scales (list[int]): The downsampling factors corresponding to the
26+
LR folders you want to process.
27+
Default: [2, 3, 4].
2528
input_folder (str): Path to the input folder.
2629
save_folder (str): Path to save folder.
2730
crop_size (int): Crop size.
@@ -31,14 +34,16 @@ def main_extract_subimages(args):
3134
3235
Usage:
3336
For each folder, run this script.
34-
Typically, there are four folders to be processed for DIV2K dataset.
37+
By default, there are four folders to be processed for DIV2K dataset
38+
according to scale factor list ([2,3,4])
3539
DIV2K_train_HR
3640
DIV2K_train_LR_bicubic/X2
3741
DIV2K_train_LR_bicubic/X3
3842
DIV2K_train_LR_bicubic/X4
3943
After process, each sub_folder should have the same number of
40-
subimages.
41-
Remember to modify opt configurations according to your settings.
44+
subimages. You can also specify scales by modifying the argument
45+
'scales'. Remember to modify opt configurations according to your
46+
settings.
4247
"""
4348

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

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

0 commit comments

Comments
 (0)