Spaces:
Runtime error
Runtime error
File size: 6,642 Bytes
2df809d |
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
import os
import glob
from tqdm import tqdm
# Define the merged dataset metadata dictionary
dataset_metadata = {
"sun_rgbd": {
"img_path": "data/sun_rgbd/image/test",
"mask_path": None,
},
"davis": {
"img_path": "data/davis/DAVIS/JPEGImages/480p",
"mask_path": "data/davis/DAVIS/masked_images/480p",
"dir_path_func": lambda img_path, seq: os.path.join(img_path, seq),
"gt_traj_func": lambda img_path, anno_path, seq: None,
"traj_format": None,
"seq_list": None,
"full_seq": True,
"mask_path_seq_func": lambda mask_path, seq: os.path.join(mask_path, seq),
"skip_condition": None,
"process_func": None, # Not used in mono depth estimation
},
"kitti": {
"img_path": "data/kitti/depth_selection/val_selection_cropped/image_gathered", # Default path
"mask_path": None,
"dir_path_func": lambda img_path, seq: os.path.join(img_path, seq),
"gt_traj_func": lambda img_path, anno_path, seq: None,
"traj_format": None,
"seq_list": None,
"full_seq": True,
"mask_path_seq_func": lambda mask_path, seq: None,
"skip_condition": None,
"process_func": lambda args, img_path: process_kitti(args, img_path),
},
"bonn": {
"img_path": "data/bonn/rgbd_bonn_dataset",
"mask_path": None,
"dir_path_func": lambda img_path, seq: os.path.join(
img_path, f"rgbd_bonn_{seq}", "rgb_110"
),
"gt_traj_func": lambda img_path, anno_path, seq: os.path.join(
img_path, f"rgbd_bonn_{seq}", "groundtruth_110.txt"
),
"traj_format": "tum",
"seq_list": ["balloon2", "crowd2", "crowd3", "person_tracking2", "synchronous"],
"full_seq": False,
"mask_path_seq_func": lambda mask_path, seq: None,
"skip_condition": None,
"process_func": lambda args, img_path: process_bonn(args, img_path),
},
"nyu": {
"img_path": "data/nyu-v2/val/nyu_images",
"mask_path": None,
"process_func": lambda args, img_path: process_nyu(args, img_path),
},
"scannet": {
"img_path": "data/scannetv2",
"mask_path": None,
"dir_path_func": lambda img_path, seq: os.path.join(img_path, seq, "color_90"),
"gt_traj_func": lambda img_path, anno_path, seq: os.path.join(
img_path, seq, "pose_90.txt"
),
"traj_format": "replica",
"seq_list": None,
"full_seq": True,
"mask_path_seq_func": lambda mask_path, seq: None,
"skip_condition": None, # lambda save_dir, seq: os.path.exists(os.path.join(save_dir, seq)),
"process_func": lambda args, img_path: process_scannet(args, img_path),
},
"tum": {
"img_path": "data/tum",
"mask_path": None,
"dir_path_func": lambda img_path, seq: os.path.join(img_path, seq, "rgb_90"),
"gt_traj_func": lambda img_path, anno_path, seq: os.path.join(
img_path, seq, "groundtruth_90.txt"
),
"traj_format": "tum",
"seq_list": None,
"full_seq": True,
"mask_path_seq_func": lambda mask_path, seq: None,
"skip_condition": None,
"process_func": None,
},
"sintel": {
"img_path": "data/sintel/training/final",
"anno_path": "data/sintel/training/camdata_left",
"mask_path": None,
"dir_path_func": lambda img_path, seq: os.path.join(img_path, seq),
"gt_traj_func": lambda img_path, anno_path, seq: os.path.join(anno_path, seq),
"traj_format": None,
"seq_list": [
"alley_2",
"ambush_4",
"ambush_5",
"ambush_6",
"cave_2",
"cave_4",
"market_2",
"market_5",
"market_6",
"shaman_3",
"sleeping_1",
"sleeping_2",
"temple_2",
"temple_3",
],
"full_seq": False,
"mask_path_seq_func": lambda mask_path, seq: None,
"skip_condition": None,
"process_func": lambda args, img_path: process_sintel(args, img_path),
},
}
# Define processing functions for each dataset
def process_kitti(args, img_path):
for dir in tqdm(sorted(glob.glob(f"{img_path}/*"))):
filelist = sorted(glob.glob(f"{dir}/*.png"))
save_dir = f"{args.output_dir}/{os.path.basename(dir)}"
yield filelist, save_dir
def process_bonn(args, img_path):
if args.full_seq:
for dir in tqdm(sorted(glob.glob(f"{img_path}/*/"))):
filelist = sorted(glob.glob(f"{dir}/rgb/*.png"))
save_dir = f"{args.output_dir}/{os.path.basename(os.path.dirname(dir))}"
yield filelist, save_dir
else:
seq_list = (
["balloon2", "crowd2", "crowd3", "person_tracking2", "synchronous"]
if args.seq_list is None
else args.seq_list
)
for seq in tqdm(seq_list):
filelist = sorted(glob.glob(f"{img_path}/rgbd_bonn_{seq}/rgb_110/*.png"))
save_dir = f"{args.output_dir}/{seq}"
yield filelist, save_dir
def process_sunrgbd(args, img_path):
filelist = sorted(glob.glob(f"{img_path}/*.jpg"))
save_dir = f"{args.output_dir}"
yield filelist, save_dir
def process_nyu(args, img_path):
filelist = sorted(glob.glob(f"{img_path}/*.png"))
save_dir = f"{args.output_dir}"
yield filelist, save_dir
def process_scannet(args, img_path):
seq_list = sorted(glob.glob(f"{img_path}/*"))
for seq in tqdm(seq_list):
filelist = sorted(glob.glob(f"{seq}/color_90/*.jpg"))
save_dir = f"{args.output_dir}/{os.path.basename(seq)}"
yield filelist, save_dir
def process_sintel(args, img_path):
if args.full_seq:
for dir in tqdm(sorted(glob.glob(f"{img_path}/*/"))):
filelist = sorted(glob.glob(f"{dir}/*.png"))
save_dir = f"{args.output_dir}/{os.path.basename(os.path.dirname(dir))}"
yield filelist, save_dir
else:
seq_list = [
"alley_2",
"ambush_4",
"ambush_5",
"ambush_6",
"cave_2",
"cave_4",
"market_2",
"market_5",
"market_6",
"shaman_3",
"sleeping_1",
"sleeping_2",
"temple_2",
"temple_3",
]
for seq in tqdm(seq_list):
filelist = sorted(glob.glob(f"{img_path}/{seq}/*.png"))
save_dir = f"{args.output_dir}/{seq}"
yield filelist, save_dir
|