karolyartur commited on
Commit
0834ca1
1 Parent(s): f633fef

Fix bug caused by dl_manager returning list instead of str

Browse files
Files changed (1) hide show
  1. oe_dataset.py +11 -5
oe_dataset.py CHANGED
@@ -25,7 +25,7 @@ else:
25
 
26
  from typing import Optional, IO
27
 
28
- import datasets
29
 
30
 
31
  # ---- Constants ----
@@ -121,20 +121,26 @@ class OEDataset(datasets.GeneratorBasedBuilder):
121
 
122
  train_masks_paths = dl_manager.download(self.config._masks_urls["train"])
123
  val_masks_paths = dl_manager.download(self.config._masks_urls["val"])
 
 
 
 
 
 
124
 
125
  return [
126
  datasets.SplitGenerator(
127
  name=datasets.Split.TRAIN,
128
  gen_kwargs={
129
- "images": dl_manager.iter_archive(train_imgs_paths),
130
- "masks": dl_manager.iter_archive(train_masks_paths),
131
  },
132
  ),
133
  datasets.SplitGenerator(
134
  name=datasets.Split.VALIDATION,
135
  gen_kwargs={
136
- "images": dl_manager.iter_archive(val_imgs_paths),
137
- "masks": dl_manager.iter_archive(val_masks_paths),
138
  },
139
  ),
140
  ]
 
25
 
26
  from typing import Optional, IO
27
 
28
+ import datasets, itertools
29
 
30
 
31
  # ---- Constants ----
 
121
 
122
  train_masks_paths = dl_manager.download(self.config._masks_urls["train"])
123
  val_masks_paths = dl_manager.download(self.config._masks_urls["val"])
124
+
125
+ train_imgs_gen = itertools.chain.from_iterable([dl_manager.iter_archive(path) for path in train_imgs_paths])
126
+ val_imgs_gen = itertools.chain.from_iterable([dl_manager.iter_archive(path) for path in val_imgs_paths])
127
+
128
+ train_masks_gen = itertools.chain.from_iterable([dl_manager.iter_archive(path) for path in train_masks_paths])
129
+ val_masks_gen = itertools.chain.from_iterable([dl_manager.iter_archive(path) for path in val_masks_paths])
130
 
131
  return [
132
  datasets.SplitGenerator(
133
  name=datasets.Split.TRAIN,
134
  gen_kwargs={
135
+ "images": train_imgs_gen,
136
+ "masks": train_masks_gen,
137
  },
138
  ),
139
  datasets.SplitGenerator(
140
  name=datasets.Split.VALIDATION,
141
  gen_kwargs={
142
+ "images": val_imgs_gen,
143
+ "masks": val_masks_gen,
144
  },
145
  ),
146
  ]