Datasets:
Size:
10K<n<100K
License:
debug custom load
Browse files- tomatotest.py +20 -11
tomatotest.py
CHANGED
@@ -17,18 +17,26 @@ class RGBSemanticDepthDataset(GeneratorBasedBuilder):
|
|
17 |
"right_depth": datasets.Image(),
|
18 |
})
|
19 |
)
|
20 |
-
def _h5_loader(self, bytes_stream):
|
21 |
# Reference: https://github.com/dwofk/fast-depth/blob/master/dataloaders/dataloader.py#L8-L13
|
22 |
f = io.BytesIO(bytes_stream)
|
23 |
h5f = h5py.File(f, "r")
|
24 |
-
print(h5f.keys())
|
25 |
left_rgb = self._read_jpg(h5f['rgb_left'][:])
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
def _read_jpg(self, bytes_stream):
|
33 |
return Image.open(io.BytesIO(bytes_stream))
|
34 |
|
@@ -43,11 +51,12 @@ class RGBSemanticDepthDataset(GeneratorBasedBuilder):
|
|
43 |
),
|
44 |
]
|
45 |
|
46 |
-
def _generate_examples(self, archives):
|
|
|
47 |
for archive in archives:
|
48 |
for path, file in archive:
|
49 |
-
print(path)
|
50 |
-
left_rgb, right_rgb, left_seg, left_depth, right_depth = self._h5_loader(file.read())
|
51 |
yield path, {
|
52 |
"left_rgb": left_rgb,
|
53 |
"right_rgb": right_rgb,
|
|
|
17 |
"right_depth": datasets.Image(),
|
18 |
})
|
19 |
)
|
20 |
+
def _h5_loader(self, bytes_stream, type_dataset):
|
21 |
# Reference: https://github.com/dwofk/fast-depth/blob/master/dataloaders/dataloader.py#L8-L13
|
22 |
f = io.BytesIO(bytes_stream)
|
23 |
h5f = h5py.File(f, "r")
|
24 |
+
#print(h5f.keys())
|
25 |
left_rgb = self._read_jpg(h5f['rgb_left'][:])
|
26 |
+
if type_dataset == 'depth':
|
27 |
+
right_rgb = self._read_jpg(h5f['rgb_right'][:])
|
28 |
+
left_depth = h5f['depth_left'][:].astype(np.float32)
|
29 |
+
right_depth = h5f['depth_right'][:].astype(np.float32)
|
30 |
+
return left_rgb, right_rgb, np.zeros((1,1)), left_depth, right_depth
|
31 |
+
elif type_dataset == 'seg':
|
32 |
+
left_seg = h5f['seg_left'][:]
|
33 |
+
return left_rgb, np.zeros((1,1)), left_seg, np.zeros((1,1)), np.zeros((1,1))
|
34 |
+
else:
|
35 |
+
right_rgb = self._read_jpg(h5f['rgb_right'][:])
|
36 |
+
left_seg = h5f['seg_left'][:]
|
37 |
+
left_depth = h5f['depth_left'][:].astype(np.float32)
|
38 |
+
right_depth = h5f['depth_right'][:].astype(np.float32)
|
39 |
+
return left_rgb, right_rgb, left_seg, left_depth, right_depth
|
40 |
def _read_jpg(self, bytes_stream):
|
41 |
return Image.open(io.BytesIO(bytes_stream))
|
42 |
|
|
|
51 |
),
|
52 |
]
|
53 |
|
54 |
+
def _generate_examples(self, archives, type_dataset='all'):
|
55 |
+
print(type_dataset)
|
56 |
for archive in archives:
|
57 |
for path, file in archive:
|
58 |
+
#print(path)
|
59 |
+
left_rgb, right_rgb, left_seg, left_depth, right_depth = self._h5_loader(file.read(), type_dataset)
|
60 |
yield path, {
|
61 |
"left_rgb": left_rgb,
|
62 |
"right_rgb": right_rgb,
|