XingjianL commited on
Commit
baa822b
1 Parent(s): 1a41c75
Files changed (1) hide show
  1. tomatotest.py +12 -8
tomatotest.py CHANGED
@@ -29,7 +29,8 @@ class RGBSemanticDepthDataset(GeneratorBasedBuilder):
29
  features=Features({
30
  "left_rgb": datasets.Image(),
31
  "right_rgb": datasets.Image(),
32
- "left_seg": datasets.Image(),
 
33
  "left_depth": datasets.Image(),
34
  "right_depth": datasets.Image(),
35
  })
@@ -43,16 +44,18 @@ class RGBSemanticDepthDataset(GeneratorBasedBuilder):
43
  right_rgb = self._read_jpg(h5f['rgb_right'][:])
44
  left_depth = h5f['depth_left'][:].astype(np.float32)
45
  right_depth = h5f['depth_right'][:].astype(np.float32)
46
- return left_rgb, right_rgb, np.zeros((1,1)), left_depth, right_depth
47
  elif type_dataset == 'seg':
48
- left_seg = h5f['seg_left'][:][:,:,::-1]
49
- return left_rgb, np.zeros((1,1)), left_seg, np.zeros((1,1)), np.zeros((1,1))
 
50
  else:
51
  right_rgb = self._read_jpg(h5f['rgb_right'][:])
52
- left_seg = h5f['seg_left'][:][:,:,::-1]
 
53
  left_depth = h5f['depth_left'][:].astype(np.float32)
54
  right_depth = h5f['depth_right'][:].astype(np.float32)
55
- return left_rgb, right_rgb, left_seg, left_depth, right_depth
56
  def _read_jpg(self, bytes_stream):
57
  return Image.open(io.BytesIO(bytes_stream))
58
 
@@ -93,11 +96,12 @@ class RGBSemanticDepthDataset(GeneratorBasedBuilder):
93
  #print(path.split('/')[-1][:-3], all_splits[0])
94
  continue
95
  #print("added")
96
- left_rgb, right_rgb, left_seg, left_depth, right_depth = self._h5_loader(file.read(), self.config.dataset_type)
97
  yield path, {
98
  "left_rgb": left_rgb,
99
  "right_rgb": right_rgb,
100
- "left_seg": left_seg,
 
101
  "left_depth": left_depth,
102
  "right_depth": right_depth,
103
  }
 
29
  features=Features({
30
  "left_rgb": datasets.Image(),
31
  "right_rgb": datasets.Image(),
32
+ "left_semantic": datasets.Image(),
33
+ "left_instance": datasets.Image(),
34
  "left_depth": datasets.Image(),
35
  "right_depth": datasets.Image(),
36
  })
 
44
  right_rgb = self._read_jpg(h5f['rgb_right'][:])
45
  left_depth = h5f['depth_left'][:].astype(np.float32)
46
  right_depth = h5f['depth_right'][:].astype(np.float32)
47
+ return left_rgb, right_rgb, np.zeros((1,1)), np.zeros((1,1)), left_depth, right_depth
48
  elif type_dataset == 'seg':
49
+ left_semantic = h5f['seg_left'][:][:,:,2]
50
+ left_instance = h5f['seg_left'][:][:,:,0] * 256 + h5f['seg_left'][:][:,:,1]
51
+ return left_rgb, np.zeros((1,1)), left_semantic, left_instance, np.zeros((1,1)), np.zeros((1,1))
52
  else:
53
  right_rgb = self._read_jpg(h5f['rgb_right'][:])
54
+ left_semantic = h5f['seg_left'][:][:,:,2]
55
+ left_instance = h5f['seg_left'][:][:,:,0] * 256 + h5f['seg_left'][:][:,:,1]
56
  left_depth = h5f['depth_left'][:].astype(np.float32)
57
  right_depth = h5f['depth_right'][:].astype(np.float32)
58
+ return left_rgb, right_rgb, left_semantic, left_instance, left_depth, right_depth
59
  def _read_jpg(self, bytes_stream):
60
  return Image.open(io.BytesIO(bytes_stream))
61
 
 
96
  #print(path.split('/')[-1][:-3], all_splits[0])
97
  continue
98
  #print("added")
99
+ left_rgb, right_rgb, left_semantic, left_instance, left_depth, right_depth = self._h5_loader(file.read(), self.config.dataset_type)
100
  yield path, {
101
  "left_rgb": left_rgb,
102
  "right_rgb": right_rgb,
103
+ "left_semantic": left_semantic,
104
+ "left_instance": left_instance,
105
  "left_depth": left_depth,
106
  "right_depth": right_depth,
107
  }