Datasets:
File size: 2,038 Bytes
1f12dc2 75314a9 1f12dc2 cade742 1f12dc2 cade742 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
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",
]
_TAR_FILES_DICT={
"00000": "data/00000.tar",
"00001": "data/00001.tar",
"00002": "data/00002.tar",
"00003": "data/00003.tar",
"00004": "data/00004.tar",
"00005": "data/00005.tar",
"00006": "data/00006.tar",
"00007": "data/00007.tar",
"00008": "data/00008.tar",
"00009": "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_DICT.keys():
archive_path = dl_manager.download(_TAR_FILES_DICT[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']
} |