aidystark commited on
Commit
ecf185b
1 Parent(s): 7c8ce3d

Create foot.py

Browse files
Files changed (1) hide show
  1. foot.py +111 -0
foot.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datasets import load_dataset
2
+ import collections
3
+ import json
4
+ import os
5
+ import datasets
6
+
7
+
8
+ _HOMEPAGE = "https://huggingface.co/datasets/aidystark/FOOTNET40k"
9
+ _LICENSE = "CC BY 4.0"
10
+ _DESCRIPTION = """\
11
+ title = { wlots Dataset },
12
+ type = { Open Source Dataset },
13
+ author = { asd },
14
+ howpublished = { \\url{ https://universe.roboflow.com/asd-culfr/wlots } },
15
+ url = { https://universe.roboflow.com/asd-culfr/wlots },
16
+ journal = { Roboflow Universe },
17
+ publisher = { Roboflow },
18
+ """
19
+ _CITATION = """\
20
+ @misc{ wlots_dataset,
21
+ title = { wlots Dataset },
22
+ type = { Open Source Dataset },
23
+ author = { asd },
24
+ howpublished = { \\url{ https://universe.roboflow.com/asd-culfr/wlots } },
25
+ url = { https://universe.roboflow.com/asd-culfr/wlots },
26
+ journal = { Roboflow Universe },
27
+ publisher = { Roboflow },
28
+ year = { 2022 },
29
+ month = { may },
30
+ note = { visited on 2023-01-27 },
31
+ }
32
+ """
33
+ #_NAMES = ["Dressing Shoe", "Crocs", "Heels", "Sneakers", "Boot", "Sandals"]
34
+ #_ANNOTATION_FILENAME = "_annotations.coco.json"
35
+
36
+
37
+ class FOOT40KConfig(datasets.BuilderConfig):
38
+ """Builder Config for FOOT40K"""
39
+
40
+ def __init__(self, data_url, metadata_url, **kwargs):
41
+ """BuilderConfig for FOOT40K.
42
+ Args:
43
+ data_url: `string`, url to download the zip file from.
44
+ metadata_urls: dictionary with keys 'train' and 'validation' containing the archive metadata URLs
45
+ **kwargs: keyword arguments forwarded to super.
46
+ """
47
+ super(FOOT40KConfig, self).__init__(version=datasets.Version("1.0.0"), **kwargs)
48
+ self.data_url = data_url
49
+ self.metadata_url = metadata_url
50
+
51
+ class FOOT40K(datasets.GeneratorBasedBuilder):
52
+ """FOOT40K Images dataset"""
53
+
54
+ BUILDER_CONFIGS = [
55
+ FOOT40KConfig(
56
+ name="shoe_all",
57
+ description="Shoe Data.",
58
+ data_url="https://huggingface.co/datasets/aidystark/FOOT40K/resolve/main/FOOT40k.tar.gz?download=true",
59
+ metadata_url = "https://huggingface.co/datasets/aidystark/FOOTNET40k/resolve/main/foot40k.json?download=true",
60
+
61
+ ),
62
+
63
+ ]
64
+
65
+ def _info(self):
66
+ return datasets.DatasetInfo(
67
+ description=_DESCRIPTION,
68
+ features=datasets.Features(
69
+ {
70
+ "image": datasets.Image(),
71
+ "text": datasets.Value("string"),
72
+ }
73
+ ),
74
+ homepage=_HOMEPAGE,
75
+ citation=_CITATION,
76
+ license=_LICENSE,
77
+ )
78
+
79
+ def _split_generators(self, dl_manager):
80
+ archive_path = dl_manager.download(self.config.data_url)
81
+ image_iters = dl_manager.iter_archive(archive_path)
82
+ metadata_path = dl_manager.download(self.config.metadata_url)
83
+ return [
84
+ datasets.SplitGenerator(
85
+ name=datasets.Split.TRAIN,
86
+ gen_kwargs={
87
+ "images": image_iters,
88
+ "metadata_path": metadata_path,
89
+ },
90
+ ),
91
+
92
+ ]
93
+
94
+
95
+ def _generate_examples(self, images, metadata_path):
96
+ idx = 0
97
+
98
+
99
+ with open(metadata_path, "r") as f:
100
+ filename_to_label = json.load(f)
101
+
102
+ labels = [item["Label"] for item in filename_to_label]
103
+
104
+
105
+ for filepath, image in images:
106
+ yield idx, {
107
+ "image": {"path": filepath, "bytes": image.read()},
108
+ "label": labels[idx],
109
+ }
110
+
111
+ idx += 1