Add README with dataset documentation
Browse files
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**:
|
| 20 |
-
- **Move In**:
|
| 21 |
-
- **Pan
|
| 22 |
-
- **
|
| 23 |
-
- **
|
| 24 |
-
- **Roll Counterclockwise**:
|
| 25 |
-
- **
|
| 26 |
-
- **Move
|
| 27 |
- **Tilt Up**: 16 questions
|
| 28 |
-
- **Move
|
| 29 |
-
- **Tilt Down**: 15 questions
|
| 30 |
-
- **Move Up**: 14 questions
|
| 31 |
- **Move Right**: 14 questions
|
| 32 |
-
- **
|
| 33 |
-
- **
|
|
|
|
|
|
|
| 34 |
|
| 35 |
|
| 36 |
## π Dataset Format
|
| 37 |
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
- `video_name`: Original video filename
|
| 40 |
-
- `
|
| 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 |
-
|
|
|
|
| 58 |
|
| 59 |
-
# Load
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
# Access a sample
|
| 63 |
-
sample =
|
| 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
|
| 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 |
-
|
| 85 |
-
output_dir = "downloaded_videos"
|
| 86 |
-
os.makedirs(output_dir, exist_ok=True)
|
| 87 |
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 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 |
-
|
|
|
|
| 106 |
```
|
| 107 |
|
| 108 |
-
|
| 109 |
|
| 110 |
-
|
| 111 |
|
| 112 |
```python
|
| 113 |
-
|
| 114 |
-
import
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
break
|
| 130 |
-
|
| 131 |
-
|
|
|
|
| 132 |
```
|
| 133 |
|
| 134 |
### Batch Processing
|
|
@@ -136,15 +119,17 @@ else:
|
|
| 136 |
For evaluation tasks:
|
| 137 |
|
| 138 |
```python
|
| 139 |
-
|
| 140 |
|
| 141 |
-
|
|
|
|
|
|
|
| 142 |
|
| 143 |
correct = 0
|
| 144 |
total = 0
|
| 145 |
|
| 146 |
-
for sample in dataset
|
| 147 |
-
video_path = sample['
|
| 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 |
-
|
| 163 |
|
| 164 |
-
|
|
|
|
| 165 |
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
huggingface-cli download cambench_binary_eval --repo-type dataset --local-dir ./cambench_data
|
| 169 |
|
| 170 |
-
#
|
| 171 |
-
|
| 172 |
-
|
|
|
|
|
|
|
| 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**:
|
|
|
|
| 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.
|