tuhink commited on
Commit
a7f9c4f
Β·
verified Β·
1 Parent(s): 007d577

Add README with dataset documentation

Browse files
Files changed (1) hide show
  1. README.md +73 -88
README.md CHANGED
@@ -16,28 +16,32 @@ A balanced VQA dataset for evaluating camera motion understanding in videos.
16
  ## 🎯 Task Categories
17
 
18
  This dataset covers various camera motion tasks including:
19
- - **Static**: 37 questions
20
- - **Move In**: 26 questions
21
- - **Pan Left**: 21 questions
22
- - **Roll Clockwise**: 20 questions
23
- - **Pan Right**: 20 questions
24
- - **Roll Counterclockwise**: 19 questions
25
- - **Move Out**: 18 questions
26
- - **Move Left**: 17 questions
27
  - **Tilt Up**: 16 questions
28
- - **Move Down**: 16 questions
29
- - **Tilt Down**: 15 questions
30
- - **Move Up**: 14 questions
31
  - **Move Right**: 14 questions
32
- - **Zoom In**: 12 questions
33
- - **Zoom Out**: 10 questions
 
 
34
 
35
 
36
  ## πŸ“ Dataset Format
37
 
38
- Each record contains:
 
 
 
 
39
  - `video_name`: Original video filename
40
- - `video`: Video file (MP4 format, original quality)
41
  - `question`: Binary question about camera motion
42
  - `label`: Answer ("Yes" or "No")
43
  - `task`: Task category
@@ -54,81 +58,60 @@ Below are animated GIF previews of sample videos from the dataset:
54
  ### Loading the Dataset
55
 
56
  ```python
57
- from datasets import load_dataset
 
58
 
59
- # Load the dataset
60
- dataset = load_dataset("cambench_binary_eval")
 
 
 
61
 
62
  # Access a sample
63
- sample = dataset['train'][0]
64
  print(f"Question: {sample['question']}")
65
  print(f"Answer: {sample['label']}")
66
  print(f"Task: {sample['task']}")
67
-
68
- # The video field contains the path to download
69
- video_file = sample['video']
70
  ```
71
 
72
- ### Downloading Videos
73
-
74
- Videos are embedded in the dataset. To download and use them:
75
-
76
- ```python
77
- from datasets import load_dataset
78
- import os
79
- import shutil
80
-
81
- # Load the dataset
82
- dataset = load_dataset("cambench_binary_eval")
83
 
84
- # Download all videos to a local directory
85
- output_dir = "downloaded_videos"
86
- os.makedirs(output_dir, exist_ok=True)
87
 
88
- for idx, sample in enumerate(dataset['train']):
89
- video_name = sample['video_name']
90
- video_data = sample['video'] # This contains the video file data
91
-
92
- # Save video to local disk
93
- local_path = os.path.join(output_dir, video_name)
94
-
95
- # If video_data is a file path (during local testing)
96
- if isinstance(video_data, str) and os.path.exists(video_data):
97
- shutil.copy2(video_data, local_path)
98
- else:
99
- # Video data from HuggingFace - write bytes to file
100
- with open(local_path, 'wb') as f:
101
- f.write(video_data)
102
-
103
- print(f"Downloaded: {video_name} -> {local_path}")
104
 
105
- print(f"All {len(dataset['train'])} videos downloaded to {output_dir}/")
 
106
  ```
107
 
108
- ### Accessing Individual Videos
109
 
110
- To download a specific video by name:
111
 
112
  ```python
113
- from datasets import load_dataset
114
- import os
115
-
116
- dataset = load_dataset("cambench_binary_eval")
117
-
118
- # Find and download a specific video
119
- target_video = "your_video_name.mp4"
120
- for sample in dataset['train']:
121
- if sample['video_name'] == target_video:
122
- video_data = sample['video']
123
-
124
- # Save to current directory
125
- with open(target_video, 'wb') as f:
126
- f.write(video_data)
127
-
128
- print(f"Downloaded: {target_video}")
129
  break
130
- else:
131
- print(f"Video {target_video} not found in dataset")
 
132
  ```
133
 
134
  ### Batch Processing
@@ -136,15 +119,17 @@ else:
136
  For evaluation tasks:
137
 
138
  ```python
139
- from datasets import load_dataset
140
 
141
- dataset = load_dataset("cambench_binary_eval")
 
 
142
 
143
  correct = 0
144
  total = 0
145
 
146
- for sample in dataset['train']:
147
- video_path = sample['video']
148
  question = sample['question']
149
  ground_truth = sample['label']
150
 
@@ -159,21 +144,21 @@ for sample in dataset['train']:
159
  # print(f"Accuracy: {accuracy:.2%}")
160
  ```
161
 
162
- ## πŸ“₯ Alternative: Download Full Dataset
163
 
164
- To download the entire dataset with all videos at once:
 
165
 
166
- ```bash
167
- # Using huggingface-cli
168
- huggingface-cli download cambench_binary_eval --repo-type dataset --local-dir ./cambench_data
169
 
170
- # Or using Python
171
- from huggingface_hub import snapshot_download
172
- snapshot_download(repo_id="cambench_binary_eval", repo_type="dataset", local_dir="./cambench_data")
 
 
173
  ```
174
 
175
- This will download all videos and data files to your local machine.
176
-
177
  ## πŸ“Š Evaluation
178
 
179
  This dataset is designed for binary classification tasks. Evaluate your model using:
@@ -196,4 +181,4 @@ For questions or issues, please open an issue on the repository.
196
 
197
  ---
198
 
199
- **Note**: Videos are provided in MP4 format. Large videos (>50MB) are automatically compressed to ensure smooth downloading and processing. All videos maintain their original temporal dynamics for accurate camera motion evaluation.
 
16
  ## 🎯 Task Categories
17
 
18
  This dataset covers various camera motion tasks including:
19
+ - **Static**: 39 questions
20
+ - **Move In**: 30 questions
21
+ - **Pan Right**: 23 questions
22
+ - **Pan Left**: 23 questions
23
+ - **Move Out**: 20 questions
24
+ - **Roll Counterclockwise**: 20 questions
25
+ - **Roll Clockwise**: 19 questions
26
+ - **Move Down**: 17 questions
27
  - **Tilt Up**: 16 questions
28
+ - **Move Up**: 16 questions
 
 
29
  - **Move Right**: 14 questions
30
+ - **Move Left**: 14 questions
31
+ - **Tilt Down**: 13 questions
32
+ - **Zoom In**: 13 questions
33
+ - **Zoom Out**: 12 questions
34
 
35
 
36
  ## πŸ“ Dataset Format
37
 
38
+ The dataset consists of:
39
+ - `videos/`: Directory containing all MP4 video files
40
+ - `metadata.jsonl`: JSONL file with question annotations
41
+
42
+ Each record in `metadata.jsonl` contains:
43
  - `video_name`: Original video filename
44
+ - `video_path`: Relative path to video file (e.g., `videos/video.mp4`)
45
  - `question`: Binary question about camera motion
46
  - `label`: Answer ("Yes" or "No")
47
  - `task`: Task category
 
58
  ### Loading the Dataset
59
 
60
  ```python
61
+ import json
62
+ import os
63
 
64
+ # Load metadata
65
+ metadata = []
66
+ with open("metadata.jsonl", "r") as f:
67
+ for line in f:
68
+ metadata.append(json.loads(line))
69
 
70
  # Access a sample
71
+ sample = metadata[0]
72
  print(f"Question: {sample['question']}")
73
  print(f"Answer: {sample['label']}")
74
  print(f"Task: {sample['task']}")
75
+ print(f"Video path: {sample['video_path']}")
 
 
76
  ```
77
 
78
+ ### Downloading the Dataset
 
 
 
 
 
 
 
 
 
 
79
 
80
+ Download the entire dataset using huggingface-cli or git:
 
 
81
 
82
+ ```bash
83
+ # Using huggingface-cli
84
+ huggingface-cli download tuhink/cambench_binary_eval --repo-type dataset --local-dir ./cambench_data
 
 
 
 
 
 
 
 
 
 
 
 
 
85
 
86
+ # Or using git
87
+ git clone https://huggingface.co/datasets/tuhink/cambench_binary_eval
88
  ```
89
 
90
+ This will download all videos and metadata to your local machine.
91
 
92
+ ### Loading Videos
93
 
94
  ```python
95
+ import json
96
+ import cv2
97
+
98
+ # Load metadata
99
+ with open("metadata.jsonl", "r") as f:
100
+ metadata = [json.loads(line) for line in f]
101
+
102
+ # Load a video
103
+ sample = metadata[0]
104
+ video_path = sample['video_path'] # e.g., "videos/video_name.mp4"
105
+
106
+ # Use OpenCV to read the video
107
+ cap = cv2.VideoCapture(video_path)
108
+ while cap.isOpened():
109
+ ret, frame = cap.read()
110
+ if not ret:
111
  break
112
+ # Process frame
113
+ pass
114
+ cap.release()
115
  ```
116
 
117
  ### Batch Processing
 
119
  For evaluation tasks:
120
 
121
  ```python
122
+ import json
123
 
124
+ # Load all questions
125
+ with open("metadata.jsonl", "r") as f:
126
+ dataset = [json.loads(line) for line in f]
127
 
128
  correct = 0
129
  total = 0
130
 
131
+ for sample in dataset:
132
+ video_path = sample['video_path']
133
  question = sample['question']
134
  ground_truth = sample['label']
135
 
 
144
  # print(f"Accuracy: {accuracy:.2%}")
145
  ```
146
 
147
+ ### Using with HuggingFace Datasets Library
148
 
149
+ ```python
150
+ from datasets import load_dataset
151
 
152
+ # Load the dataset
153
+ dataset = load_dataset("tuhink/cambench_binary_eval")
 
154
 
155
+ # Access samples
156
+ for sample in dataset['train']:
157
+ print(f"Question: {sample['question']}")
158
+ print(f"Answer: {sample['label']}")
159
+ print(f"Video: {sample['video_path']}")
160
  ```
161
 
 
 
162
  ## πŸ“Š Evaluation
163
 
164
  This dataset is designed for binary classification tasks. Evaluate your model using:
 
181
 
182
  ---
183
 
184
+ **Note**: All videos are provided in original MP4 format. The dataset maintains temporal dynamics for accurate camera motion evaluation.