XingjianL commited on
Commit
5a009ef
1 Parent(s): f160861

test commit

Browse files
Files changed (2) hide show
  1. data/images_1730238419.175364.tar +3 -0
  2. tomatotest.py +56 -0
data/images_1730238419.175364.tar ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:81bdfde7484ffae73be482ee3aefdb4f58bbe1b3031130b183e6d8024d2a6824
3
+ size 880778240
tomatotest.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import io
2
+ from PIL import Image
3
+ from datasets import GeneratorBasedBuilder, DatasetInfo, Features, SplitGenerator, Value, Array2D, Split
4
+ import datasets
5
+ import OpenEXR
6
+ import Imath
7
+ import numpy as np
8
+ import h5py
9
+ class RGBSemanticDepthDataset(GeneratorBasedBuilder):
10
+ def _info(self):
11
+ return DatasetInfo(
12
+ features=Features({
13
+ "left_rgb": datasets.Image(),
14
+ "right_rgb": datasets.Image(),
15
+ "left_seg": datasets.Image(),
16
+ "left_depth": datasets.Image(),
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
+ left_rgb = self._read_jpg(h5f['rgb_left'])
25
+ right_rgb = self._read_jpg(h5f['rgb_right'])
26
+ left_seg = h5f['seg_left']
27
+ left_depth = h5f['depth_left'].astype(np.float32)
28
+ right_depth = h5f['depth_right'].astype(np.float32)
29
+ print(left_rgb.shape, left_depth.shape, left_seg.shape)
30
+ return left_rgb, right_rgb, left_seg, left_depth, right_depth
31
+ def _read_jpg(self, bytes_stream):
32
+ return Image.open(io.BytesIO(bytes_stream))
33
+
34
+ def _split_generators(self, dl_manager):
35
+ archives = dl_manager.download({"train":["data/images_1729368304.063240.tar"]})
36
+ return [
37
+ SplitGenerator(
38
+ name=Split.TRAIN,
39
+ gen_kwargs={
40
+ "archives": [dl_manager.iter_archive(archive) for archive in archives["train"]],
41
+ },
42
+ ),
43
+ ]
44
+
45
+ def _generate_examples(self, archives):
46
+ for archive in archives:
47
+ for path, file in archive:
48
+ print(path)
49
+ left_rgb, right_rgb, left_seg, left_depth, right_depth = self._h5_loader(file.read())
50
+ yield path, {
51
+ "left_rgb": left_rgb,
52
+ "right_rgb": right_rgb,
53
+ "left_seg": left_seg,
54
+ "left_depth": left_depth,
55
+ "right_depth": right_depth,
56
+ }