jaradat commited on
Commit
a01208f
·
1 Parent(s): cbc4833

Upload pidray-semantics.py

Browse files
Files changed (1) hide show
  1. pidray-semantics.py +83 -0
pidray-semantics.py ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
81
+
82
+
83
+