|
import collections |
|
import json |
|
import os |
|
import datasets |
|
|
|
|
|
_HOMEPAGE = "https://huggingface.co/datasets/aidystark/FOOTNET40k" |
|
_LICENSE = "CC BY 4.0" |
|
|
|
|
|
|
|
|
|
|
|
class FOOT40KConfig(datasets.BuilderConfig): |
|
"""Builder Config for FOOT40K""" |
|
|
|
def __init__(self, data_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 |
|
|
|
|
|
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", |
|
|
|
|
|
), |
|
|
|
] |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
features=datasets.Features( |
|
{ |
|
"image": datasets.Image(), |
|
|
|
} |
|
), |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
|
|
|
|
|
|
|
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={ |
|
"images": dl_manager.iter_archive(dl_manager.download(self.config.data_url)), |
|
|
|
}, |
|
), |
|
|
|
] |
|
|
|
|
|
def _generate_examples(self, images ): |
|
for file_path, file_obj in images: |
|
yield file_path, { |
|
"image": {"path": file_path, "bytes": file_obj.read()}, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|