def create_lmdb_for_reds(): """Create lmdb files for REDS dataset. Usage: Before run this script, please run `merge_reds_train_val.py`. We take two folders for example: train_sharp train_sharp_bicubic Remember to modify opt configurations according to your settings. """ # train_sharp folder_path = 'datasets/REDS/train_sharp' lmdb_path = 'datasets/REDS/train_sharp_with_val.lmdb' img_path_list, keys = prepare_keys_reds(folder_path) make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys, multiprocessing_read=True) # train_sharp_bicubic folder_path = 'datasets/REDS/train_sharp_bicubic' lmdb_path = 'datasets/REDS/train_sharp_bicubic_with_val.lmdb' img_path_list, keys = prepare_keys_reds(folder_path) make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys, multiprocessing_read=True)
def create_lmdb_for_vimeo90k(): """Create lmdb files for Vimeo90K dataset. Usage: Remember to modify opt configurations according to your settings. """ # GT folder_path = 'datasets/vimeo90k/vimeo_septuplet/sequences' lmdb_path = 'datasets/vimeo90k/vimeo90k_train_GT_only4th.lmdb' train_list_path = 'datasets/vimeo90k/vimeo_septuplet/sep_trainlist.txt' img_path_list, keys = prepare_keys_vimeo90k(folder_path, train_list_path, 'gt') make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys, multiprocessing_read=True) # LQ folder_path = 'datasets/vimeo90k/vimeo_septuplet_matlabLRx4/sequences' lmdb_path = 'datasets/vimeo90k/vimeo90k_train_LR7frames.lmdb' train_list_path = 'datasets/vimeo90k/vimeo_septuplet/sep_trainlist.txt' img_path_list, keys = prepare_keys_vimeo90k(folder_path, train_list_path, 'lq') make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys, multiprocessing_read=True)
def create_lmdb_for_rain13k(): folder_path = './datasets/Rain13k/train/input' lmdb_path = './datasets/Rain13k/train/input.lmdb' img_path_list, keys = prepare_keys(folder_path, 'jpg') make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys) folder_path = './datasets/Rain13k/train/target' lmdb_path = './datasets/Rain13k/train/target.lmdb' img_path_list, keys = prepare_keys(folder_path, 'jpg') make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys)
def create_lmdb_for_div2k(): """Create lmdb files for DIV2K dataset. Usage: Before run this script, please run `extract_subimages.py`. Typically, there are four folders to be processed for DIV2K dataset. DIV2K_train_HR_sub DIV2K_train_LR_bicubic/X2_sub DIV2K_train_LR_bicubic/X3_sub DIV2K_train_LR_bicubic/X4_sub Remember to modify opt configurations according to your settings. """ # HR images folder_path = 'datasets/DIV2K/DIV2K_train_HR_sub' lmdb_path = 'datasets/DIV2K/DIV2K_train_HR_sub.lmdb' img_path_list, keys = prepare_keys_div2k(folder_path) make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys) # LRx2 images folder_path = 'datasets/DIV2K/DIV2K_train_LR_bicubic/X2_sub' lmdb_path = 'datasets/DIV2K/DIV2K_train_LR_bicubic_X2_sub.lmdb' img_path_list, keys = prepare_keys_div2k(folder_path) make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys) # LRx3 images folder_path = 'datasets/DIV2K/DIV2K_train_LR_bicubic/X3_sub' lmdb_path = 'datasets/DIV2K/DIV2K_train_LR_bicubic_X3_sub.lmdb' img_path_list, keys = prepare_keys_div2k(folder_path) make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys) # LRx4 images folder_path = 'datasets/DIV2K/DIV2K_train_LR_bicubic/X4_sub' lmdb_path = 'datasets/DIV2K/DIV2K_train_LR_bicubic_X4_sub.lmdb' img_path_list, keys = prepare_keys_div2k(folder_path) make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys)
def create_lmdb_for_SIDD(): folder_path = './datasets/SIDD/train/input_crops' lmdb_path = './datasets/SIDD/train/input_crops.lmdb' img_path_list, keys = prepare_keys(folder_path, 'PNG') make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys) folder_path = './datasets/SIDD/train/gt_crops' lmdb_path = './datasets/SIDD/train/gt_crops.lmdb' img_path_list, keys = prepare_keys(folder_path, 'PNG') make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys) #for val folder_path = './datasets/SIDD/val/input_crops' lmdb_path = './datasets/SIDD/val/input_crops.lmdb' mat_path = './datasets/SIDD/ValidationNoisyBlocksSrgb.mat' if not osp.exists(folder_path): os.makedirs(folder_path) assert osp.exists(mat_path) data = scio.loadmat(mat_path)['ValidationNoisyBlocksSrgb'] N, B, H, W, C = data.shape data = data.reshape(N * B, H, W, C) for i in tqdm(range(N * B)): cv2.imwrite( osp.join(folder_path, 'ValidationBlocksSrgb_{}.png'.format(i)), cv2.cvtColor(data[i, ...], cv2.COLOR_RGB2BGR)) img_path_list, keys = prepare_keys(folder_path, 'png') make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys) folder_path = './datasets/SIDD/val/gt_crops' lmdb_path = './datasets/SIDD/val/gt_crops.lmdb' mat_path = './datasets/SIDD/ValidationGtBlocksSrgb.mat' if not osp.exists(folder_path): os.makedirs(folder_path) assert osp.exists(mat_path) data = scio.loadmat(mat_path)['ValidationGtBlocksSrgb'] N, B, H, W, C = data.shape data = data.reshape(N * B, H, W, C) for i in tqdm(range(N * B)): cv2.imwrite( osp.join(folder_path, 'ValidationBlocksSrgb_{}.png'.format(i)), cv2.cvtColor(data[i, ...], cv2.COLOR_RGB2BGR)) img_path_list, keys = prepare_keys(folder_path, 'png') make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys)
def create_lmdb_for_reds(): folder_path = './datasets/REDS/val/sharp_300' lmdb_path = './datasets/REDS/val/sharp_300.lmdb' img_path_list, keys = prepare_keys(folder_path, 'png') make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys) # folder_path = './datasets/REDS/val/blur_300' lmdb_path = './datasets/REDS/val/blur_300.lmdb' img_path_list, keys = prepare_keys(folder_path, 'jpg') make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys) folder_path = './datasets/REDS/train/train_sharp' lmdb_path = './datasets/REDS/train/train_sharp.lmdb' img_path_list, keys = prepare_keys(folder_path, 'png') make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys) folder_path = './datasets/REDS/train/train_blur_jpeg' lmdb_path = './datasets/REDS/train/train_blur_jpeg.lmdb' img_path_list, keys = prepare_keys(folder_path, 'jpg') make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys)
def create_lmdb_for_gopro(): folder_path = './datasets/GoPro/train/blur_crops' lmdb_path = './datasets/GoPro/train/blur_crops.lmdb' img_path_list, keys = prepare_keys(folder_path, 'png') make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys) folder_path = './datasets/GoPro/train/sharp_crops' lmdb_path = './datasets/GoPro/train/sharp_crops.lmdb' img_path_list, keys = prepare_keys(folder_path, 'png') make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys) folder_path = './datasets/GoPro/test/target' lmdb_path = './datasets/GoPro/test/target.lmdb' img_path_list, keys = prepare_keys(folder_path, 'png') make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys) folder_path = './datasets/GoPro/test/input' lmdb_path = './datasets/GoPro/test/input.lmdb' img_path_list, keys = prepare_keys(folder_path, 'png') make_lmdb_from_imgs(folder_path, lmdb_path, img_path_list, keys)