Upload fashion.py
Browse files- fashion.py +106 -0
fashion.py
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
"""SQUAD: The Stanford Question Answering Dataset."""
|
18 |
+
|
19 |
+
|
20 |
+
import json
|
21 |
+
|
22 |
+
import datasets
|
23 |
+
from datasets.tasks import QuestionAnsweringExtractive
|
24 |
+
|
25 |
+
|
26 |
+
logger = datasets.logging.get_logger(__name__)
|
27 |
+
|
28 |
+
|
29 |
+
_CITATION = """\
|
30 |
+
@article{2016arXiv160605250R,
|
31 |
+
author = {{Rajpurkar}, Pranav and {Zhang}, Jian and {Lopyrev},
|
32 |
+
Konstantin and {Liang}, Percy},
|
33 |
+
title = "{SQuAD: 100,000+ Questions for Machine Comprehension of Text}",
|
34 |
+
journal = {arXiv e-prints},
|
35 |
+
year = 2016,
|
36 |
+
eid = {arXiv:1606.05250},
|
37 |
+
pages = {arXiv:1606.05250},
|
38 |
+
archivePrefix = {arXiv},
|
39 |
+
eprint = {1606.05250},
|
40 |
+
}
|
41 |
+
"""
|
42 |
+
|
43 |
+
_DESCRIPTION = """\
|
44 |
+
Stanford Question Answering Dataset (SQuAD) is a reading comprehension \
|
45 |
+
dataset, consisting of questions posed by crowdworkers on a set of Wikipedia \
|
46 |
+
articles, where the answer to every question is a segment of text, or span, \
|
47 |
+
from the corresponding reading passage, or the question might be unanswerable.
|
48 |
+
"""
|
49 |
+
|
50 |
+
_URL = "https://huggingface.co/datasets/proan/fashion/resolve/main/images.tar.gz"
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
class Fashion(datasets.GeneratorBasedBuilder):
|
56 |
+
"""SQUAD: The Stanford Question Answering Dataset. Version 1.1."""
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
+
def _info(self):
|
61 |
+
return datasets.DatasetInfo(
|
62 |
+
description=_DESCRIPTION,
|
63 |
+
features=datasets.Features(
|
64 |
+
{
|
65 |
+
"id": datasets.Value("int64"),
|
66 |
+
"color": datasets.Value("string"),
|
67 |
+
"description": datasets.Value("string"),
|
68 |
+
"shop_id": datasets.Value("string"),
|
69 |
+
"year": datasets.Value("float64"),
|
70 |
+
"image": datasets.Image(),
|
71 |
+
}
|
72 |
+
),
|
73 |
+
# No default supervised_keys (as we have to pass both question
|
74 |
+
# and context as input).
|
75 |
+
supervised_keys=None,
|
76 |
+
homepage="https://huggingface.co/datasets/proan/fashion",
|
77 |
+
citation=_CITATION,
|
78 |
+
|
79 |
+
)
|
80 |
+
|
81 |
+
def _split_generators(self, dl_manager):
|
82 |
+
path = dl_manager.download_and_extract(_URL)
|
83 |
+
image_iters = dl_manager.iter_archive(path)
|
84 |
+
|
85 |
+
return [
|
86 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"images": image_iters}),
|
87 |
+
|
88 |
+
]
|
89 |
+
|
90 |
+
def _generate_examples(self, images):
|
91 |
+
|
92 |
+
idx = 0
|
93 |
+
#iterate through images
|
94 |
+
for filepath, image in images:
|
95 |
+
yield idx, {
|
96 |
+
"image": {"path": filepath, "image": image.read()},
|
97 |
+
"id": datasets.Value("int64"),
|
98 |
+
"color": datasets.Value("string"),
|
99 |
+
"description": datasets.Value("string"),
|
100 |
+
"shop_id": datasets.Value("string"),
|
101 |
+
"year": datasets.Value("float64"),
|
102 |
+
"image": datasets.Image(),
|
103 |
+
}
|
104 |
+
idx +=1
|
105 |
+
|
106 |
+
|