File size: 1,112 Bytes
0e8a20f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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