MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / __init__

Method __init__

eval_code/recons/datasets/dtu.py:65–119  ·  view source on GitHub ↗
(
        self,
        DTU_DIR: str,
        split: str = "test",
        load_img_size: int = 518,
        cache_file: str = "data/dataset_cache/dtu_mv_recon_cache.npy",
    )

Source from the content-addressed store, hash-verified

63
64class DTU(Dataset):
65 def __init__(
66 self,
67 DTU_DIR: str,
68 split: str = "test",
69 load_img_size: int = 518,
70 cache_file: str = "data/dataset_cache/dtu_mv_recon_cache.npy",
71 ):
72
73 self.DTU_DIR = DTU_DIR
74 if DTU_DIR == None:
75 raise NotImplementedError
76 print(f"DTU_DIR is {DTU_DIR}")
77
78 self.split = split
79 assert split == 'test', "Only test set preprocessed."
80 if self.split == 'train':
81 seq_numbers = [
82 2, 6, 7, 8, 14, 16, 18, 19, 20, 22, 30, 31, 36, 39, 41, 42, 44,
83 45, 46, 47, 50, 51, 52, 53, 55, 57, 58, 60, 61, 63, 64, 65, 68, 69, 70, 71, 72,
84 74, 76, 83, 84, 85, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
85 101, 102, 103, 104, 105, 107, 108, 109, 111, 112, 113, 115, 116, 119, 120,
86 121, 122, 123, 124, 125, 126, 127, 128
87 ]
88 elif self.split == 'valid':
89 seq_numbers = [3, 5, 17, 21, 28, 35, 37, 38, 40, 43, 56, 59, 66, 67, 82, 86, 106, 117]
90 elif self.split == 'test':
91 seq_numbers = [1, 4, 9, 10, 11, 12, 13, 15, 23, 24, 29, 32, 33, 34, 48, 49, 62, 75, 77, 110, 114, 118]
92 else:
93 raise ValueError(f"Invalid split: {self.split}. Must be 'train', 'valid' or 'test'.")
94
95 if osp.exists(cache_file):
96 print(f"[DTU] Loading from cache file: {cache_file}")
97 self.metadata = np.load(cache_file, allow_pickle=True).item()
98 self.sequence_list = sorted(list(self.metadata.keys()))
99 else:
100 print(f"[DTU] Cache file not found, loading from {DTU_DIR}")
101
102 self.sequence_list = [f"scan{num}" for num in seq_numbers]
103
104 self.metadata = {}
105 for seq in tqdm(self.sequence_list):
106 rgb_root = osp.join(DTU_DIR, seq, 'images')
107
108 all_imgs = sorted([d for d in os.listdir(rgb_root) if d.endswith('.jpg')])
109
110 all_img_numbers = [int(imgname.split('.')[0]) for imgname in all_imgs]
111 if all_img_numbers[0] != 0 or all_img_numbers[-1] + 1 != len(all_img_numbers):
112 raise ValueError(f"Image number not regular, with first image {all_imgs[0]} and last image {all_imgs[-1]} but number of images {len(all_imgs)}")
113
114 self.metadata[seq] = len(all_imgs)
115
116 np.save(cache_file, self.metadata)
117
118 self.load_img_size = load_img_size
119 print(f"[DTU] Data size: {len(self)}")
120
121 def __len__(self):
122 return len(self.sequence_list)

Callers

nothing calls this directly

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected