| 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 |
|
|