File size: 1,793 Bytes
2817b4d |
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 |
import datasets
import os
from pathlib import Path
_DESCRIPTION = """
CameraBench Binary Evaluation Dataset with video frames and optical flow visualizations.
"""
class CameraBenchConfig(datasets.BuilderConfig):
"""BuilderConfig for CameraBench."""
def __init__(self, **kwargs):
super(CameraBenchConfig, self).__init__(**kwargs)
class CameraBench(datasets.GeneratorBasedBuilder):
"""CameraBench dataset with frames and optical flows."""
VERSION = datasets.Version("1.0.0")
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features({
"video_name": datasets.Value("string"),
"video_path": datasets.Value("string"),
"frames_path": datasets.Value("string"),
"optical_flows_path": datasets.Value("string"),
"first_frame": datasets.Image(),
"first_flow": datasets.Image(),
"num_frames": datasets.Value("int32"),
"num_flows": datasets.Value("int32"),
"question": datasets.Value("string"),
"label": datasets.Value("string"),
"task": datasets.Value("string"),
"label_name": datasets.Value("string"),
})
)
def _split_generators(self, dl_manager):
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={"metadata_path": "data.jsonl"},
),
]
def _generate_examples(self, metadata_path):
import json
idx = 0
with open(metadata_path, "r") as f:
for line in f:
record = json.loads(line)
yield idx, record
idx += 1
|