XingjianL commited on
Commit
09039e6
1 Parent(s): acc9038

test custom argument

Browse files
Files changed (1) hide show
  1. tomatotest.py +12 -5
tomatotest.py CHANGED
@@ -2,11 +2,18 @@ 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({
@@ -51,12 +58,12 @@ class RGBSemanticDepthDataset(GeneratorBasedBuilder):
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,
 
2
  from PIL import Image
3
  from datasets import GeneratorBasedBuilder, DatasetInfo, Features, SplitGenerator, Value, Array2D, Split
4
  import datasets
 
 
5
  import numpy as np
6
  import h5py
7
+ class CustomConfig(datasets.BuilderConfig):
8
+ def __init__(self, **kwargs):
9
+ self.dataset_type = kwargs.pop("dataset_type", "all")
10
+ super(CustomConfig, self).__init__(**kwargs)
11
+
12
  class RGBSemanticDepthDataset(GeneratorBasedBuilder):
13
+ BUILDER_CONFIGS = [
14
+ CustomConfig(name="custom_config", version="1.0.0", description="")
15
+ ] # Configs initialization
16
+ BUILDER_CONFIG_CLASS = CustomConfig
17
  def _info(self):
18
  return DatasetInfo(
19
  features=Features({
 
58
  ),
59
  ]
60
 
61
+ def _generate_examples(self, archives):
62
+ print(self.dataset_type)
63
  for archive in archives:
64
  for path, file in archive:
65
  #print(path)
66
+ left_rgb, right_rgb, left_seg, left_depth, right_depth = self._h5_loader(file.read(), self.dataset_type)
67
  yield path, {
68
  "left_rgb": left_rgb,
69
  "right_rgb": right_rgb,