tempofunk-old / tempofunk.py
chavinlo's picture
Update tempofunk.py
75314a9
raw
history blame
1.67 kB
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']
}