XingjianL commited on
Commit
c2447c9
1 Parent(s): cc7508e
Files changed (1) hide show
  1. tomatotest.py +28 -18
tomatotest.py CHANGED
@@ -12,9 +12,9 @@ class CustomConfig(datasets.BuilderConfig):
12
 
13
  class RGBSemanticDepthDataset(GeneratorBasedBuilder):
14
  BUILDER_CONFIGS = [
15
- CustomConfig(name="all", version="1.0.0", description="all"),
16
- CustomConfig(name="depth", version="1.0.0", description="depth"),
17
- CustomConfig(name="seg", version="1.0.0", description="segmentation"),
18
  ] # Configs initialization
19
  BUILDER_CONFIG_CLASS = CustomConfig
20
  def _info(self):
@@ -31,7 +31,6 @@ class RGBSemanticDepthDataset(GeneratorBasedBuilder):
31
  # Reference: https://github.com/dwofk/fast-depth/blob/master/dataloaders/dataloader.py#L8-L13
32
  f = io.BytesIO(bytes_stream)
33
  h5f = h5py.File(f, "r")
34
- print(type_dataset)
35
  left_rgb = self._read_jpg(h5f['rgb_left'][:])
36
  if type_dataset == 'depth':
37
  right_rgb = self._read_jpg(h5f['rgb_right'][:])
@@ -56,21 +55,32 @@ class RGBSemanticDepthDataset(GeneratorBasedBuilder):
56
  SplitGenerator(
57
  name=Split.TRAIN,
58
  gen_kwargs={
59
- "archives": [dl_manager.iter_archive(archive) for archive in archives["train"]],
 
 
 
 
 
 
 
 
60
  },
61
  ),
62
  ]
63
 
64
- def _generate_examples(self, archives):
65
- print(self.config.dataset_type)
66
- for archive in archives:
67
- for path, file in archive:
68
- #print(path)
69
- left_rgb, right_rgb, left_seg, left_depth, right_depth = self._h5_loader(file.read(), self.config.dataset_type)
70
- yield path, {
71
- "left_rgb": left_rgb,
72
- "right_rgb": right_rgb,
73
- "left_seg": left_seg,
74
- "left_depth": left_depth,
75
- "right_depth": right_depth,
76
- }
 
 
 
 
12
 
13
  class RGBSemanticDepthDataset(GeneratorBasedBuilder):
14
  BUILDER_CONFIGS = [
15
+ CustomConfig(name="all", version="1.0.0", description="load both segmentation and depth"),
16
+ CustomConfig(name="depth", version="1.0.0", description="only load depth"),
17
+ CustomConfig(name="seg", version="1.0.0", description="only load segmentation"),
18
  ] # Configs initialization
19
  BUILDER_CONFIG_CLASS = CustomConfig
20
  def _info(self):
 
31
  # Reference: https://github.com/dwofk/fast-depth/blob/master/dataloaders/dataloader.py#L8-L13
32
  f = io.BytesIO(bytes_stream)
33
  h5f = h5py.File(f, "r")
 
34
  left_rgb = self._read_jpg(h5f['rgb_left'][:])
35
  if type_dataset == 'depth':
36
  right_rgb = self._read_jpg(h5f['rgb_right'][:])
 
55
  SplitGenerator(
56
  name=Split.TRAIN,
57
  gen_kwargs={
58
+ "archives": [dl_manager.iter_archive(archive) for archive in archives],
59
+ "split_txt": "train.txt"
60
+ },
61
+ ),
62
+ SplitGenerator(
63
+ name=Split.VAL,
64
+ gen_kwargs={
65
+ "archives": [dl_manager.iter_archive(archive) for archive in archives],
66
+ "split_txt": "val.txt"
67
  },
68
  ),
69
  ]
70
 
71
+ def _generate_examples(self, archives, split_txt):
72
+ with open(split_txt) as split_f:
73
+ all_splits = split_f.read().split('\n')
74
+ print(all_splits)
75
+ for archive in archives:
76
+ for path, file in archive:
77
+ if path not in all_splits:
78
+ continue
79
+ left_rgb, right_rgb, left_seg, left_depth, right_depth = self._h5_loader(file.read(), self.config.dataset_type)
80
+ yield path, {
81
+ "left_rgb": left_rgb,
82
+ "right_rgb": right_rgb,
83
+ "left_seg": left_seg,
84
+ "left_depth": left_depth,
85
+ "right_depth": right_depth,
86
+ }