-
Notifications
You must be signed in to change notification settings - Fork 5
/
prep.py
36 lines (22 loc) · 1 KB
/
prep.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import argparse, os
import multiprocessing as mp
from importlib import import_module
from src.datahandler import get_dataset_class
def main():
# parsing configuration
args = argparse.ArgumentParser()
args.add_argument('-d', '--dataset', default='SIDD', type=str)
args.add_argument('-s', '--patch_size', default=512, type=int)
args.add_argument('-o', '--overlap', default=128, type=int)
args.add_argument('-p', '--process', default=8, type=int)
args = args.parse_args()
assert args.dataset != '', 'dataset name is needed'
dataset = get_dataset_class(args.dataset)()
# check what the dataset have images
data_sample = dataset.__getitem__(0)
flag_c, flag_n = 'clean' in data_sample, 'real_noisy' in data_sample
pool = mp.Pool(args.process)
mp_args = [[data_idx, args.patch_size, args.overlap, flag_c, False, flag_n] for data_idx in range(dataset.__len__())]
pool.starmap(dataset.prep_save, mp_args)
if __name__ == '__main__':
main()