def main(): dataset_dir = Path(args.dataset_dir) if args.dump_root == None: args.dump_root = Path( '/home/roit/datasets') / dataset_dir.stem + '_256512' else: args.dump_root = Path(args.dump_root) args.dump_root.mkdir_p() global data_loader if args.dataset_format == 'kitti': from kitti_raw_loader import KittiRawLoader data_loader = KittiRawLoader(args.dataset_dir, static_frames_file=args.static_frames, img_height=args.height, img_width=args.width, get_gt=args.with_gt) if args.dataset_format == 'cityscapes': from cityscapes_loader import cityscapes_loader data_loader = cityscapes_loader(args.dataset_dir, img_height=args.height, img_width=args.width) if args.dataset_format == 'visdrone': from visdrone_raw_loader import VisDroneRawLoader data_loader = VisDroneRawLoader(args.dataset_dir, static_frames_file=args.static_frames, img_height=args.height, img_width=args.width, get_gt=args.with_gt) if args.dataset_format == 'minecraft': from minecraft_loader import MCLoader data_loader = MCLoader(args.dataset_dir, static_frames_file=args.static_frames, img_height=args.height, img_width=args.width, gt_depth=args.with_gt) pass print('Retrieving frames') #joblib.delayed #Parallel(n_jobs=args.num_threads)(delayed(dump_example)(scene) for scene in tqdm(data_loader.scenes)) for scene in data_loader.scenes: dump_example(scene) # Split into train/val print('Generating train val lists') np.random.seed(8964) subfolders = args.dump_root.dirs() with open(args.dump_root / 'train.txt', 'w') as tf: with open(args.dump_root / 'val.txt', 'w') as vf: for s in tqdm(subfolders): if np.random.random() < 0.1: #随机分割 vf.write('{}\n'.format(s.name)) else: tf.write('{}\n'.format(s.name)) # remove useless groundtruth data for training comment if you don't want to erase it for gt_file in s.files('*.npy'): gt_file.remove_p()
def main(): args.dump_root = Path(args.dump_root) args.dump_root.mkdir_p() global data_loader if args.dataset_format == 'kitti': from kitti_raw_loader import KittiRawLoader data_loader = KittiRawLoader(args.dataset_dir, static_frames_file=args.static_frames, img_height=args.height, img_width=args.width, get_gt=args.with_gt) if args.dataset_format == 'cityscapes': from cityscapes_loader import cityscapes_loader data_loader = cityscapes_loader(args.dataset_dir, img_height=args.height, img_width=args.width) print('Retrieving frames') Parallel(n_jobs=args.num_threads)(delayed(dump_example)(scene) for scene in tqdm(data_loader.scenes)) # Split into train/val print('Generating train val lists') np.random.seed(8964) subfolders = args.dump_root.dirs() with open(args.dump_root / 'train.txt', 'w') as tf: with open(args.dump_root / 'val.txt', 'w') as vf: for s in tqdm(subfolders): if np.random.random() < 0.1: vf.write('{}\n'.format(s.name)) else: tf.write('{}\n'.format(s.name))
def main(): args.dump_root = Path(args.dump_root) args.dump_root.mkdir_p() global data_loader if args.dataset_format == 'kitti': from kitti_raw_loader import KittiRawLoader data_loader = KittiRawLoader(args.dataset_dir, static_frames_file=args.static_frames, img_height=args.height, img_width=args.width, get_gt=args.with_gt) if args.dataset_format == 'cityscapes': from cityscapes_loader import cityscapes_loader data_loader = cityscapes_loader(args.dataset_dir, img_height=args.height, img_width=args.width) print('Retrieving frames') def convert_scenes(missing_folders): date = missing_folders[0][:10] root = Path('/content/drive/MyDrive/Dự án/KITTI Dataset/Raw Data' + f'/{date}') converted = [] for folder in missing_folders: converted.append(root / folder[:-3]) return converted missing_folders = [] scenes = convert_scenes(missing_folders) Parallel(n_jobs=args.num_threads)(delayed(dump_example)(scene) for scene in tqdm(scenes))
def main(): args.dump_root = Path(args.dump_root) args.dump_root.mkdir_p() global data_loader if args.dataset_format == 'kitti': from kitti_raw_loader import KittiRawLoader data_loader = KittiRawLoader(args.dataset_dir, static_frames_file=args.static_frames, img_height=args.height, img_width=args.width, get_depth=args.with_depth, get_pose=args.with_pose, depth_size_ratio=args.depth_size_ratio) if args.dataset_format == 'cityscapes': from cityscapes_loader import cityscapes_loader data_loader = cityscapes_loader(args.dataset_dir, img_height=args.height, img_width=args.width) n_scenes = len(data_loader.scenes) print("n_scenes:",n_scenes) print('Found {} potential scenes'.format(n_scenes)) print('Retrieving frames') if args.num_threads == 1: for scene in tqdm(data_loader.scenes): print("scene:",scene) dump_example(args, scene) else: with ProcessPool(max_workers=args.num_threads) as pool: tasks = pool.map(dump_example, [args]*n_scenes, data_loader.scenes) try: for _ in tqdm(tasks.result(), total=n_scenes): pass except KeyboardInterrupt as e: tasks.cancel() raise e print('Generating train val lists') np.random.seed(8964) # to avoid data snooping, we will make two cameras of the same scene to fall in the same set, train or val subdirs = args.dump_root.dirs() canonic_prefixes = set([subdir.basename()[:-2] for subdir in subdirs]) with open(args.dump_root / 'train.txt', 'w') as tf: with open(args.dump_root / 'val.txt', 'w') as vf: for pr in tqdm(canonic_prefixes): corresponding_dirs = args.dump_root.dirs('{}*'.format(pr)) if np.random.random() < 0.1: for s in corresponding_dirs: vf.write('{}\n'.format(s.name)) else: for s in corresponding_dirs: tf.write('{}\n'.format(s.name)) if args.with_depth and args.no_train_gt: for gt_file in s.files('*.npy'): gt_file.remove_p()
def main(): args.dump_root = Path(args.dump_root) args.dump_root.mkdir_p() global data_loader if args.dataset_format == 'kitti': from kitti_raw_loader import KittiRawLoader data_loader = KittiRawLoader(args.dataset_dir, static_frames_file=args.static_frames, img_height=args.height, img_width=args.width, get_depth=args.with_depth, get_pose=args.with_pose, depth_size_ratio=args.depth_size_ratio) if args.dataset_format == 'cityscapes': from cityscapes_loader import cityscapes_loader data_loader = cityscapes_loader(args.dataset_dir, img_height=args.height, img_width=args.width) print('Retrieving frames') if args.num_threads == 1: for scene in tqdm(data_loader.scenes): dump_example(args, scene) else: Parallel(n_jobs=args.num_threads)( delayed(dump_example)(args, scene) for scene in tqdm(data_loader.scenes)) print('Generating train val lists') np.random.seed(8964) # to avoid data snooping, we will make two cameras of the same scene to fall in the same set, train or val subdirs = args.dump_root.dirs() canonic_prefixes = set([subdir.basename()[:-2] for subdir in subdirs]) with open(args.dump_root / 'train.txt', 'w') as tf: with open(args.dump_root / 'val.txt', 'w') as vf: for pr in tqdm(canonic_prefixes): corresponding_dirs = args.dump_root.dirs('{}*'.format(pr)) if np.random.random() < 0.1: for s in corresponding_dirs: vf.write('{}\n'.format(s.name)) else: for s in corresponding_dirs: tf.write('{}\n'.format(s.name)) if args.with_depth and args.no_train_gt: for gt_file in s.files('*.npy'): gt_file.remove_p()
def main(): args.dump_root = Path(args.dump_root) args.dump_root.mkdir_p() global data_loader if args.dataset_format == 'kitti': from kitti_raw_loader import KittiRawLoader data_loader = KittiRawLoader(args.dataset_dir, static_frames_file=args.static_frames, img_height=args.height, img_width=args.width, get_depth=args.with_depth, get_pose=args.with_pose) if args.dataset_format == 'cityscapes': from cityscapes_loader import cityscapes_loader data_loader = cityscapes_loader(args.dataset_dir, img_height=args.height, img_width=args.width) print('Retrieving frames') if args.num_threads == 1: for scene in tqdm(data_loader.scenes): dump_example(scene) else: Parallel(n_jobs=args.num_threads)( delayed(dump_example)(scene) for scene in tqdm(data_loader.scenes)) print('Generating train val lists') np.random.seed(8964) subfolders = args.dump_root.dirs() with open(args.dump_root / 'train.txt', 'w') as tf: with open(args.dump_root / 'val.txt', 'w') as vf: for s in tqdm(subfolders): if np.random.random() < 0.1: vf.write('{}\n'.format(s.name)) else: tf.write('{}\n'.format(s.name)) if args.with_gt: # remove useless groundtruth data for training comment if you don't want to erase it s / 'poses.txt'.remove_p() for gt_file in s.files('*.npy'): gt_file.remove_p()
def main(): args.dump_root = Path(args.dump_root) args.dump_root.mkdir_p() global data_loader if args.dataset_format == 'kitti': from kitti_raw_loader import KittiRawLoader data_loader = KittiRawLoader(args.dataset_dir, static_frames_file=args.static_frames, img_height=args.height, img_width=args.width) elif args.dataset_format == "kitti_odom": from kitti_odometry_loader import KittiOdometryLoader data_loader = KittiOdometryLoader( args.dataset_dir, static_frames_file=args.static_frames, img_height=args.height, img_width=args.width, seq_length=5, train_list="./data/odometry_train.txt", val_list="./data/odometry_val.txt") elif args.dataset_format == 'cityscapes': raise ("Not Implemented Error") else: raise ("Please use assigned argument by dataset_format") print('Retrieving frames') Parallel(n_jobs=args.num_threads)(delayed(dump_example)(scene) for scene in tqdm(data_loader.scenes)) # Split into train/val print('Generating train val lists') np.random.seed(8964) subfolders = args.dump_root.dirs() with open(args.dump_root / 'train.txt', 'w') as tf: with open(args.dump_root / 'val.txt', 'w') as vf: for s in tqdm(subfolders): if np.random.random( ) < 0.1 and args.dataset_format != "kitti_odom": vf.write('{}\n'.format(s.name)) else: tf.write('{}\n'.format(s.name))
def main(): args.dump_root = Path(args.dump_root) args.dump_root.mkdir_p() global data_loader data_loader = KittiRawLoader( args.dataset_dir, static_frames_file=args.static_frames, img_height=args.height, img_width=args.width, ) print('Retrieving frames') for scene in data_loader.scenes: print(scene) if args.num_threads == 1: for scene in tqdm(data_loader.scenes): dump_example(scene, args) else: Parallel(n_jobs=args.num_threads)( delayed(dump_example)(scene, args) for scene in tqdm(data_loader.scenes)) print('Generating train val lists') np.random.seed(8964) # to avoid data snooping, we will make two cameras of the same scene to fall in the same set, train or val subdirs = args.dump_root.dirs() canonic_prefixes = set([subdir.basename()[:-2] for subdir in subdirs]) with open(args.dump_root / 'train.txt', 'w') as tf: with open(args.dump_root / 'val.txt', 'w') as vf: for pr in tqdm(canonic_prefixes): corresponding_dirs = args.dump_root.dirs('{}*'.format(pr)) if np.random.random() < 0.1: for s in corresponding_dirs: vf.write('{}\n'.format(s.name)) else: for s in corresponding_dirs: tf.write('{}\n'.format(s.name))