Datasets:
pierreguillou
commited on
Commit
•
c8c38c8
1
Parent(s):
293f7c7
Update DocLayNet-small.py
Browse files- DocLayNet-small.py +21 -13
DocLayNet-small.py
CHANGED
@@ -157,32 +157,40 @@ class DocLayNet(datasets.GeneratorBasedBuilder):
|
|
157 |
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
158 |
|
159 |
downloaded_file = dl_manager.download_and_extract("https://huggingface.co/datasets/pierreguillou/DocLayNet-small/resolve/main/data/dataset_small.zip")
|
160 |
-
|
161 |
-
|
|
|
|
|
162 |
name=datasets.Split.TRAIN,
|
163 |
# These kwargs will be passed to _generate_examples
|
164 |
gen_kwargs={
|
165 |
-
"filepath":
|
166 |
"split": "train",
|
167 |
},
|
168 |
-
)
|
169 |
-
|
|
|
170 |
name=datasets.Split.VALIDATION,
|
171 |
# These kwargs will be passed to _generate_examples
|
172 |
gen_kwargs={
|
173 |
-
"filepath":
|
174 |
-
"split": "
|
175 |
},
|
176 |
-
)
|
177 |
-
|
|
|
178 |
name=datasets.Split.TEST,
|
179 |
# These kwargs will be passed to _generate_examples
|
180 |
gen_kwargs={
|
181 |
-
"filepath":
|
182 |
-
"split": "test"
|
183 |
},
|
184 |
-
)
|
185 |
-
|
|
|
|
|
|
|
|
|
186 |
|
187 |
def _generate_examples(self, filepath, split):
|
188 |
logger.info("⏳ Generating examples from = %s", filepath)
|
|
|
157 |
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
158 |
|
159 |
downloaded_file = dl_manager.download_and_extract("https://huggingface.co/datasets/pierreguillou/DocLayNet-small/resolve/main/data/dataset_small.zip")
|
160 |
+
splits = []
|
161 |
+
for split in self.config.splits:
|
162 |
+
if split == "train":
|
163 |
+
dataset = datasets.SplitGenerator(
|
164 |
name=datasets.Split.TRAIN,
|
165 |
# These kwargs will be passed to _generate_examples
|
166 |
gen_kwargs={
|
167 |
+
"filepath": os.path.join(downloaded_file, "small_dataset/train/"),
|
168 |
"split": "train",
|
169 |
},
|
170 |
+
)
|
171 |
+
elif split in ["val", "valid", "validation", "dev"]:
|
172 |
+
dataset = datasets.SplitGenerator(
|
173 |
name=datasets.Split.VALIDATION,
|
174 |
# These kwargs will be passed to _generate_examples
|
175 |
gen_kwargs={
|
176 |
+
"filepath": os.path.join(downloaded_file, "small_dataset/val/"),
|
177 |
+
"split": "val",
|
178 |
},
|
179 |
+
)
|
180 |
+
elif split in ["test"]:
|
181 |
+
dataset = datasets.SplitGenerator(
|
182 |
name=datasets.Split.TEST,
|
183 |
# These kwargs will be passed to _generate_examples
|
184 |
gen_kwargs={
|
185 |
+
"filepath": os.path.join(downloaded_file, "small_dataset/test/"),
|
186 |
+
"split": "test",
|
187 |
},
|
188 |
+
)
|
189 |
+
else:
|
190 |
+
continue
|
191 |
+
|
192 |
+
splits.append(dataset)
|
193 |
+
return splits
|
194 |
|
195 |
def _generate_examples(self, filepath, split):
|
196 |
logger.info("⏳ Generating examples from = %s", filepath)
|