File size: 1,673 Bytes
1f12dc2
 
 
 
 
75314a9
 
 
 
 
 
 
 
 
 
1f12dc2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import datasets
from io import BytesIO
import numpy as np

_TAR_FILES=[
    "data/00000.tar",
    "data/00001.tar",
    "data/00002.tar",
    "data/00003.tar",
    "data/00004.tar",
    "data/00005.tar",
    "data/00006.tar",
    "data/00007.tar",
    "data/00008.tar",
    "data/00009.tar",
    ]

class Food101(datasets.GeneratorBasedBuilder):
    """Food-101 Images dataset."""

    def _info(self):
        return datasets.DatasetInfo(
            description="TMP description",
            homepage="google it",
            citation="lmao",
            license="dunno, tbh, assume the worst, k thx."
        )

    def _split_generators(self, dl_manager):
        
        l=[]
        for k in _TAR_FILES:
            archive_path = dl_manager.download(k)
            l.append(
                datasets.SplitGenerator(
                name=k,
                gen_kwargs={
                    "npy_files": dl_manager.iter_archive(archive_path),
                },)
            )
            
        return l

    def _generate_examples(self, npy_files):
        """Generate images and labels for splits."""
        for file_path, file_obj in npy_files:
            # NOTE: File object is (ALREADY) opened in binary mode.
            numpy_bytes = file_obj.read()
            numpy_dict = np.load(BytesIO(numpy_bytes), allow_pickle=True)

            reconverted_dict = {
                "frames": numpy_dict.item().get("frames"),
                "prompt": numpy_dict.item().get("prompt")
            }

            yield file_path, {
                "tokenized_prompt": reconverted_dict['prompt'],
                "video": reconverted_dict['frames']
                }