File size: 1,858 Bytes
d7b40cf 44641b3 6b36ce6 a01208f 44641b3 a01208f d7b40cf 6b36ce6 d7b40cf a01208f 6b36ce6 d7b40cf a01208f 6b36ce6 44641b3 a01208f d7b40cf a01208f d7b40cf 6b36ce6 9c6dc5e a01208f 6b36ce6 a01208f 6b36ce6 a01208f 6b36ce6 a01208f 6b36ce6 f04c768 a63a31d 32537ac d7b40cf a63a31d 32537ac 44641b3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
import json
import datasets
from datasets.tasks import QuestionAnsweringExtractive
logger = datasets.logging.get_logger(__name__)
_URL = "https://huggingface.co/datasets/jaradat/pidray-semantics/resolve/main/pixel_values.tar.gz"
_URL2 = "https://huggingface.co/datasets/jaradat/pidray-semantics/resolve/main/label.tar.gz"
class pidraySemantics(datasets.GeneratorBasedBuilder):
def _info(self):
return datasets.DatasetInfo(
features=datasets.Features(
{
#"text": datasets.Value("string"),
"pixel_values": datasets.Image(),
"label": datasets.Image(),
}
),
# No default supervised_keys (as we have to pass both question
# and context as input).
supervised_keys=None,
homepage="https://huggingface.co/datasets/jaradat/pidray-semantics",
)
def _split_generators(self, dl_manager):
path = dl_manager.download(_URL)
image_iters = dl_manager.iter_archive(path)
path2 = dl_manager.download(_URL2)
label_iters = dl_manager.iter_archive(path2)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"images": image_iters,
"label": label_iters
}
),
]
def _generate_examples(self, images, label):
idx = 0
# iterate through images
for (filepath, image), (filepath2, image2) in zip(images, label):
yield idx, {
"pixel_values": {"path": filepath, "bytes": image.read()},
"label": {"path": filepath2, "bytes": image2.read()},
}
idx += 1
|