kjunh commited on
Commit
3e99dde
·
1 Parent(s): 001a680

[Script] Download script

Browse files
Files changed (1) hide show
  1. EgoSpeak.py +59 -0
EgoSpeak.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ from datasets import DatasetInfo, Features, GeneratorBasedBuilder, Split, Value
4
+
5
+
6
+ class EgoSpeak(GeneratorBasedBuilder):
7
+ """EgoSpeak Dataset with EasyCom, Ego4D, and YTConv subdirectories."""
8
+
9
+ VERSION = "1.0.0"
10
+
11
+ def _info(self):
12
+ return DatasetInfo(
13
+ description="EgoSpeak dataset containing precomputed features from EasyCom, Ego4D, and YTConv.",
14
+ features=Features(
15
+ {
16
+ "sub_dir": Value("string"),
17
+ "src_video_filename": Value("string"),
18
+ "file_path": Value("string"),
19
+ }
20
+ ),
21
+ homepage="https://huggingface.co/datasets/kjunh/EgoSpeak",
22
+ license="CC BY-NC 4.0",
23
+ citation="""\
24
+ @article{egospeak,
25
+ title={...}
26
+ author={NAME},
27
+ journal={ArXiv/Conference},
28
+ year={2024}
29
+ }
30
+ """,
31
+ )
32
+
33
+ def _split_generators(self, dl_manager):
34
+ # Path to the dataset directory (change if different)
35
+ data_dir = os.path.abspath(dl_manager.manual_dir)
36
+ return [
37
+ SplitGenerator(
38
+ name=Split.TRAIN,
39
+ gen_kwargs={"data_dir": data_dir},
40
+ ),
41
+ ]
42
+
43
+ def _generate_examples(self, data_dir):
44
+ """Generate examples from the dataset directory structure."""
45
+ idx = 0
46
+ for root, dirs, files in os.walk(data_dir):
47
+ # Filter for .npy files
48
+ for file_name in files:
49
+ if file_name.endswith(".npy"):
50
+ file_path = os.path.join(root, file_name)
51
+ sub_dir = os.path.relpath(root, data_dir)
52
+ src_video_filename = file_name.replace(".npy", "")
53
+
54
+ yield idx, {
55
+ "sub_dir": sub_dir,
56
+ "src_video_filename": src_video_filename,
57
+ "file_path": file_path,
58
+ }
59
+ idx += 1