Update Tuberculosis_Dataset.py
Browse files- Tuberculosis_Dataset.py +10 -11
Tuberculosis_Dataset.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
from datasets import DatasetBuilder, DownloadManager, DatasetInfo, Array3D, BuilderConfig, SplitGenerator, Version, Split
|
| 2 |
from datasets.features import Features, Value, Sequence
|
| 3 |
import pandas as pd
|
| 4 |
-
import datasets
|
| 5 |
import json
|
| 6 |
import zipfile
|
| 7 |
from PIL import Image
|
|
@@ -18,20 +17,20 @@ Nievas Offidani, M. and Delrieux, C. (2023) “The MultiCaRe Dataset: A Multimod
|
|
| 18 |
class TuberculosisDataset(DatasetBuilder):
|
| 19 |
# Define dataset's name
|
| 20 |
BUILDER_CONFIGS = [
|
| 21 |
-
BuilderConfig(name="tuberculosis_dataset", version=
|
| 22 |
]
|
| 23 |
|
| 24 |
def _info(self):
|
| 25 |
return DatasetInfo(
|
| 26 |
description = _DESCRIPTION,
|
| 27 |
features=Features({
|
| 28 |
-
"case_id":
|
| 29 |
-
"gender":
|
| 30 |
-
"age":
|
| 31 |
-
"case_text":
|
| 32 |
-
"keywords":
|
| 33 |
-
"image_arrays":
|
| 34 |
-
"caption":
|
| 35 |
}),
|
| 36 |
supervised_keys = None,
|
| 37 |
homepage = "https://zenodo.org/api/records/10079370/files-archive",
|
|
@@ -50,7 +49,7 @@ class TuberculosisDataset(DatasetBuilder):
|
|
| 50 |
downloaded_files = dl_manager.download_and_extract(urls)
|
| 51 |
|
| 52 |
return [
|
| 53 |
-
|
| 54 |
]
|
| 55 |
|
| 56 |
def _generate_examples(self, cases_csv, keywords_json, caption_json, image_filenames_json, images_zip):
|
|
@@ -99,4 +98,4 @@ class TuberculosisDataset(DatasetBuilder):
|
|
| 99 |
image_arrays[pmcid].append(img_array.tolist())
|
| 100 |
else:
|
| 101 |
image_arrays[pmcid] = [img_array.tolist()]
|
| 102 |
-
return image_arrays
|
|
|
|
| 1 |
from datasets import DatasetBuilder, DownloadManager, DatasetInfo, Array3D, BuilderConfig, SplitGenerator, Version, Split
|
| 2 |
from datasets.features import Features, Value, Sequence
|
| 3 |
import pandas as pd
|
|
|
|
| 4 |
import json
|
| 5 |
import zipfile
|
| 6 |
from PIL import Image
|
|
|
|
| 17 |
class TuberculosisDataset(DatasetBuilder):
|
| 18 |
# Define dataset's name
|
| 19 |
BUILDER_CONFIGS = [
|
| 20 |
+
BuilderConfig(name="tuberculosis_dataset", version=Version("1.0.0"))
|
| 21 |
]
|
| 22 |
|
| 23 |
def _info(self):
|
| 24 |
return DatasetInfo(
|
| 25 |
description = _DESCRIPTION,
|
| 26 |
features=Features({
|
| 27 |
+
"case_id": Value("string"),
|
| 28 |
+
"gender": Value("string"),
|
| 29 |
+
"age": Value("int8"),
|
| 30 |
+
"case_text": Value("string"),
|
| 31 |
+
"keywords": Value("string"),
|
| 32 |
+
"image_arrays": Sequence(Array3D(dtype="uint8")),
|
| 33 |
+
"caption": Value("string"),
|
| 34 |
}),
|
| 35 |
supervised_keys = None,
|
| 36 |
homepage = "https://zenodo.org/api/records/10079370/files-archive",
|
|
|
|
| 49 |
downloaded_files = dl_manager.download_and_extract(urls)
|
| 50 |
|
| 51 |
return [
|
| 52 |
+
SplitGenerator(name=Split.TRAIN, gen_kwargs=downloaded_files),
|
| 53 |
]
|
| 54 |
|
| 55 |
def _generate_examples(self, cases_csv, keywords_json, caption_json, image_filenames_json, images_zip):
|
|
|
|
| 98 |
image_arrays[pmcid].append(img_array.tolist())
|
| 99 |
else:
|
| 100 |
image_arrays[pmcid] = [img_array.tolist()]
|
| 101 |
+
return image_arrays
|