File size: 2,853 Bytes
ecf185b f2b302b ecf185b 438dc29 ecf185b f2b302b ecf185b 438dc29 ecf185b 438dc29 ecf185b 438dc29 ecf185b f83798b c1ada15 f83798b 755234e ecf185b f83798b ecf185b b9611c1 438dc29 b9611c1 ecf185b b9611c1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
import collections
import json
import os
import datasets
_HOMEPAGE = "https://huggingface.co/datasets/aidystark/FOOTNET40k"
_LICENSE = "CC BY 4.0"
#_NAMES = ["Dressing Shoe", "Crocs", "Heels", "Sneakers", "Boot", "Sandals"]
#_ANNOTATION_FILENAME = "_annotations.coco.json"
class FOOT40KConfig(datasets.BuilderConfig):
"""Builder Config for FOOT40K"""
def __init__(self, data_url, **kwargs):# metadata_url, **kwargs):
"""BuilderConfig for FOOT40K.
Args:
data_url: `string`, url to download the zip file from.
metadata_url:
**kwargs: keyword arguments forwarded to super.
"""
super(FOOT40KConfig, self).__init__(version=datasets.Version("1.0.0"), **kwargs)
self.data_url = data_url
#self.metadata_url = metadata_url
class FOOT40K(datasets.GeneratorBasedBuilder):
"""FOOT40K Images dataset"""
BUILDER_CONFIGS = [
FOOT40KConfig(
name="shoe_all",
description="Shoe Data.",
data_url="https://huggingface.co/datasets/aidystark/FOOT40K/resolve/main/FOOT40k.tar.gz?download=true",
#metadata_url = "https://huggingface.co/datasets/aidystark/FOOT40K/resolve/main/foot40k.json?download=true",
),
]
def _info(self):
return datasets.DatasetInfo(
features=datasets.Features(
{
"image": datasets.Image(),
#"Label": datasets.Value("string"),
}
),
homepage=_HOMEPAGE,
license=_LICENSE,
)
def _split_generators(self, dl_manager):
#archive_path = dl_manager.download(self.config.data_url)
#image_iters = dl_manager.iter_archive(archive_path)
#metadata_path = dl_manager.download(self.config.metadata_url)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"images": dl_manager.iter_archive(dl_manager.download(self.config.data_url)),
#"images": image_iters,#"metadata_path": metadata_path,
},
),
]
def _generate_examples(self, images ): #, metadata_path):
for file_path, file_obj in images:
yield file_path, {
"image": {"path": file_path, "bytes": file_obj.read()},
#"solution": Path(file_path).name.split('.')[0],
}
#idx = 0
#with open(metadata_path, "r") as f:
# filename_to_label = json.load(f)
#labels = [item["Label"] for item in filename_to_label]
#for filepath, image in images:
# yield idx, {
# "image": {"path": filepath, "bytes": image.read()},
# #"label": labels[idx],
# }
# idx += 1 |