|
import json |
|
import datasets |
|
|
|
_URL="https://huggingface.co/datasets/aadhiya/image-upoload/resolve/main/images.tar.gz" |
|
class Builddata(datasets.GeneratorBasedBuilder): |
|
def _info(self): |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=datasets.Features( |
|
{ |
|
"text":datasets.Value("string"), |
|
"image":datasets.Image(), |
|
} |
|
), |
|
supervised_keys=None |
|
) |
|
def _split_generators(self,dl_manager): |
|
path=dl_manager.download(_URL) |
|
image_iters=dl_manager.iter_archive(path) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={ |
|
"images":image_iters |
|
} |
|
), |
|
] |
|
|
|
|
|
def _generate_examples(self,images): |
|
idx=0 |
|
for filepath,image in images: |
|
yield idx,{ |
|
"image":{"path":filepath,"bytes":image.read()}, |
|
"text":descriptions[idx] |
|
} |
|
idx+=1 |
|
|