Delete storyframes.py
Browse files- storyframes.py +0 -56
storyframes.py
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
from datasets import load_from_disk, DatasetDict
|
3 |
-
|
4 |
-
|
5 |
-
def load_storyframes(config, split=None):
|
6 |
-
"""
|
7 |
-
Load the StoryFrames dataset for a given configuration and split.
|
8 |
-
|
9 |
-
Args:
|
10 |
-
config (str): The configuration name, e.g. "scene_4_7", "scene_8_plus", etc.
|
11 |
-
split (str, optional): The split to load ("train" or "val"). If None,
|
12 |
-
tries to load both splits and returns a DatasetDict.
|
13 |
-
|
14 |
-
Returns:
|
15 |
-
A Dataset (if split is specified) or a DatasetDict (if split is None).
|
16 |
-
"""
|
17 |
-
base_dir = os.path.join(os.path.dirname(__file__), config)
|
18 |
-
if split:
|
19 |
-
split_path = os.path.join(base_dir, split)
|
20 |
-
return load_from_disk(split_path)
|
21 |
-
else:
|
22 |
-
splits = {}
|
23 |
-
for sp in ["train", "val"]:
|
24 |
-
split_path = os.path.join(base_dir, sp)
|
25 |
-
if os.path.exists(split_path):
|
26 |
-
splits[sp] = load_from_disk(split_path)
|
27 |
-
if splits:
|
28 |
-
return DatasetDict(splits)
|
29 |
-
else:
|
30 |
-
raise FileNotFoundError(
|
31 |
-
f"No splits found for configuration '{config}' in {base_dir}."
|
32 |
-
)
|
33 |
-
|
34 |
-
|
35 |
-
if __name__ == "__main__":
|
36 |
-
import argparse
|
37 |
-
|
38 |
-
parser = argparse.ArgumentParser(
|
39 |
-
description="Load a specific StoryFrames configuration and split."
|
40 |
-
)
|
41 |
-
parser.add_argument(
|
42 |
-
"--config",
|
43 |
-
type=str,
|
44 |
-
default="scene_4_7",
|
45 |
-
help="Configuration name (e.g., scene_4_7)",
|
46 |
-
)
|
47 |
-
parser.add_argument(
|
48 |
-
"--split",
|
49 |
-
type=str,
|
50 |
-
default="val",
|
51 |
-
help="Split to load (train/val); omit to load both",
|
52 |
-
)
|
53 |
-
args = parser.parse_args()
|
54 |
-
|
55 |
-
ds = load_storyframes(args.config, args.split)
|
56 |
-
print(ds)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|