aidystark commited on
Commit
665c529
1 Parent(s): 1bfc58f

Create script.py

Browse files
Files changed (1) hide show
  1. script.py +84 -0
script.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2021 The HuggingFace Datasets Authors and the current dataset script contributor.
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
+ """Dataset class for Shoe40k dataset."""
16
+
17
+ import datasets
18
+ from datasets.tasks import ImageClassification
19
+ import pandas as pd
20
+ import json
21
+ import requests
22
+
23
+
24
+ _HOMEPAGE = "https://huggingface.co/datasets/aidystark/shoe41k"
25
+
26
+ _DESCRIPTION = (
27
+ "----------------------------------------"
28
+ )
29
+
30
+ _CITATION = """\
31
+
32
+ """
33
+
34
+ _LICENSE = """\
35
+ LICENSE AGREEMENT
36
+ =================
37
+ """
38
+
39
+ _NAMES = ['Dressing Shoe', 'Boot', 'Crocs', 'Heels', 'Sandals', 'Sneakers']
40
+ _CSV = "https://huggingface.co/datasets/aidystark/shoe41k/resolve/main/FOOT40K.csv"
41
+ _URL = "https://huggingface.co/datasets/aidystark/shoe41k/resolve/main/shoe40k"
42
+
43
+
44
+
45
+ df = pd.read_csv(_CSV)
46
+ imgLabels = df['Label']
47
+
48
+
49
+ class shoe40k(datasets.GeneratorBasedBuilder):
50
+ """-------"""
51
+
52
+ def _info(self):
53
+ return datasets.DatasetInfo(
54
+ description=_DESCRIPTION,
55
+ features=datasets.Features(
56
+ {
57
+ "image": datasets.Image(),
58
+ "label": datasets.ClassLabel(names=_NAMES),
59
+ }
60
+ ),
61
+ supervised_keys=("image", "label"),
62
+ homepage=_HOMEPAGE,
63
+ citation=_CITATION,
64
+ license=_LICENSE,
65
+ task_templates=[ImageClassification(image_column="image", label_column="label")],
66
+ )
67
+
68
+ def _split_generators(self, dl_manager):
69
+ path = dl_manager.download(_URL)
70
+ image_iters = dl_manager.iter_archive(path)
71
+ return [datasets.SplitGenerator(datasets.Split.TRAIN,gen_kwargs={"images":image_iters,})]
72
+
73
+
74
+ def _generate_examples(self, images):
75
+ """Generate images and labels for splits."""
76
+ idx = 0
77
+ #Iterate through images
78
+ for filepath,image in images:
79
+ yield idx, {
80
+ "image":{"path":filepath, "bytes":image.read()},
81
+ "label":imgLabels[idx]
82
+ }
83
+ idx += 1
84
+