ibrahimahmood
commited on
Upload 4 files
Browse files- images.zip +3 -0
- labels.tarz.zip +3 -0
- pidray-semantics.py +60 -0
- pidray-targz.py +80 -0
images.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ad6d6d6cb582aeea7843f4e33d7e8d767252d32a2ff16cb72b39e7cc63bfaad3
|
3 |
+
size 135662992
|
labels.tarz.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cfa8ff3b95accf47303c7276c2d6da2cb00f4b544f2ba217399b5eaa7275911c
|
3 |
+
size 3681280
|
pidray-semantics.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import json
|
3 |
+
|
4 |
+
import datasets
|
5 |
+
from datasets.tasks import QuestionAnsweringExtractive
|
6 |
+
|
7 |
+
|
8 |
+
logger = datasets.logging.get_logger(__name__)
|
9 |
+
|
10 |
+
_URL = "https://huggingface.co/datasets/jaradat/pidray-semantics/resolve/main/pixel_values.tar.gz"
|
11 |
+
_URL2 = "https://huggingface.co/datasets/jaradat/pidray-semantics/resolve/main/label.tar.gz"
|
12 |
+
|
13 |
+
class pidraySemantics(datasets.GeneratorBasedBuilder):
|
14 |
+
|
15 |
+
def _info(self):
|
16 |
+
return datasets.DatasetInfo(
|
17 |
+
features=datasets.Features(
|
18 |
+
{
|
19 |
+
#"text": datasets.Value("string"),
|
20 |
+
"pixel_values": datasets.Image(),
|
21 |
+
"label": datasets.Image(),
|
22 |
+
}
|
23 |
+
),
|
24 |
+
# No default supervised_keys (as we have to pass both question
|
25 |
+
# and context as input).
|
26 |
+
supervised_keys=None,
|
27 |
+
homepage="https://huggingface.co/datasets/jaradat/pidray-semantics",
|
28 |
+
|
29 |
+
)
|
30 |
+
|
31 |
+
def _split_generators(self, dl_manager):
|
32 |
+
path = dl_manager.download(_URL)
|
33 |
+
image_iters = dl_manager.iter_archive(path)
|
34 |
+
|
35 |
+
|
36 |
+
path2 = dl_manager.download(_URL2)
|
37 |
+
label_iters = dl_manager.iter_archive(path2)
|
38 |
+
|
39 |
+
return [
|
40 |
+
datasets.SplitGenerator(
|
41 |
+
name=datasets.Split.TRAIN,
|
42 |
+
gen_kwargs={
|
43 |
+
"images": image_iters,
|
44 |
+
"label": label_iters
|
45 |
+
}
|
46 |
+
),
|
47 |
+
|
48 |
+
]
|
49 |
+
|
50 |
+
def _generate_examples(self, images, label):
|
51 |
+
idx = 0
|
52 |
+
# iterate through images
|
53 |
+
|
54 |
+
for (filepath, image), (filepath2, image2) in zip(images, label):
|
55 |
+
|
56 |
+
yield idx, {
|
57 |
+
"pixel_values": {"path": filepath, "bytes": image.read()},
|
58 |
+
"label": {"path": filepath2, "bytes": image2.read()},
|
59 |
+
}
|
60 |
+
idx += 1
|
pidray-targz.py
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
|
16 |
+
# Lint as: python3
|
17 |
+
|
18 |
+
|
19 |
+
import json
|
20 |
+
|
21 |
+
import datasets
|
22 |
+
from datasets.tasks import QuestionAnsweringExtractive
|
23 |
+
|
24 |
+
|
25 |
+
logger = datasets.logging.get_logger(__name__)
|
26 |
+
|
27 |
+
_URL = "https://huggingface.co/datasets/jaradat/pidray-semantics/resolve/main/pixel_values.tar.gz"
|
28 |
+
_URL2 = "https://huggingface.co/datasets/jaradat/pidray-semantics/resolve/main/label.tar.gz"
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
class PIDrayTargz(datasets.GeneratorBasedBuilder):
|
33 |
+
|
34 |
+
def _info(self):
|
35 |
+
return datasets.DatasetInfo(
|
36 |
+
features=datasets.Features(
|
37 |
+
{
|
38 |
+
#"text": datasets.Value("string"),
|
39 |
+
"pixel_values": datasets.Image(),
|
40 |
+
"label": datasets.Image(),
|
41 |
+
}
|
42 |
+
),
|
43 |
+
# No default supervised_keys (as we have to pass both question
|
44 |
+
# and context as input).
|
45 |
+
supervised_keys=None,
|
46 |
+
homepage="https://huggingface.co/datasets/jaradat/pidray-semantics",
|
47 |
+
|
48 |
+
)
|
49 |
+
|
50 |
+
def _split_generators(self, dl_manager):
|
51 |
+
path = dl_manager.download(_URL)
|
52 |
+
image_iters = dl_manager.iter_archive(path)
|
53 |
+
|
54 |
+
|
55 |
+
path2 = dl_manager.download(_URL2)
|
56 |
+
label_iters = dl_manager.iter_archive(path2)
|
57 |
+
|
58 |
+
return [
|
59 |
+
datasets.SplitGenerator(
|
60 |
+
name=datasets.Split.TRAIN,
|
61 |
+
gen_kwargs={
|
62 |
+
"images": image_iters,
|
63 |
+
"label": label_iters
|
64 |
+
}
|
65 |
+
),
|
66 |
+
|
67 |
+
]
|
68 |
+
|
69 |
+
def _generate_examples(self, images, label):
|
70 |
+
"""This function returns the examples in the raw (text) form."""
|
71 |
+
idx = 0
|
72 |
+
# iterate through images
|
73 |
+
for filepath, image in images
|
74 |
+
|
75 |
+
text = filepath.split
|
76 |
+
yield idx, {
|
77 |
+
"pixel_values": {"filepath": filepath, "image": image.read()},
|
78 |
+
"label": {"filepath": label[idx]['filepath'], "label": label[idx]['image'].read()},
|
79 |
+
}
|
80 |
+
idx += 1
|