Datasets:
Create tempofunk.py
Browse files- tempofunk.py +59 -0
tempofunk.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import datasets
|
2 |
+
from io import BytesIO
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
_TAR_FILES=[
|
6 |
+
"data/0000.tar",
|
7 |
+
"data/0001.tar",
|
8 |
+
"data/0002.tar",
|
9 |
+
"data/0003.tar",
|
10 |
+
"data/0004.tar",
|
11 |
+
"data/0005.tar",
|
12 |
+
"data/0006.tar",
|
13 |
+
"data/0007.tar",
|
14 |
+
"data/0008.tar",
|
15 |
+
"data/0009.tar",
|
16 |
+
]
|
17 |
+
|
18 |
+
class Food101(datasets.GeneratorBasedBuilder):
|
19 |
+
"""Food-101 Images dataset."""
|
20 |
+
|
21 |
+
def _info(self):
|
22 |
+
return datasets.DatasetInfo(
|
23 |
+
description="TMP description",
|
24 |
+
homepage="google it",
|
25 |
+
citation="lmao",
|
26 |
+
license="dunno, tbh, assume the worst, k thx."
|
27 |
+
)
|
28 |
+
|
29 |
+
def _split_generators(self, dl_manager):
|
30 |
+
|
31 |
+
l=[]
|
32 |
+
for k in _TAR_FILES:
|
33 |
+
archive_path = dl_manager.download(k)
|
34 |
+
l.append(
|
35 |
+
datasets.SplitGenerator(
|
36 |
+
name=k,
|
37 |
+
gen_kwargs={
|
38 |
+
"npy_files": dl_manager.iter_archive(archive_path),
|
39 |
+
},)
|
40 |
+
)
|
41 |
+
|
42 |
+
return l
|
43 |
+
|
44 |
+
def _generate_examples(self, npy_files):
|
45 |
+
"""Generate images and labels for splits."""
|
46 |
+
for file_path, file_obj in npy_files:
|
47 |
+
# NOTE: File object is (ALREADY) opened in binary mode.
|
48 |
+
numpy_bytes = file_obj.read()
|
49 |
+
numpy_dict = np.load(BytesIO(numpy_bytes), allow_pickle=True)
|
50 |
+
|
51 |
+
reconverted_dict = {
|
52 |
+
"frames": numpy_dict.item().get("frames"),
|
53 |
+
"prompt": numpy_dict.item().get("prompt")
|
54 |
+
}
|
55 |
+
|
56 |
+
yield file_path, {
|
57 |
+
"tokenized_prompt": reconverted_dict['prompt'],
|
58 |
+
"video": reconverted_dict['frames']
|
59 |
+
}
|