Rowan commited on
Commit
1e55229
·
verified ·
1 Parent(s): 5f940f9

Add dataset card and compatibility files

Browse files
.gitattributes CHANGED
@@ -58,3 +58,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
 
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
+ original_annotations/test.jsonl filter=lfs diff=lfs merge=lfs -text
62
+ original_annotations/train.jsonl filter=lfs diff=lfs merge=lfs -text
63
+ original_annotations/val.jsonl filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,227 +1,83 @@
1
  ---
2
- dataset_info:
3
- - config_name: image_examples
4
- features:
5
- - name: image
6
- dtype: image
7
- - name: img_fn
8
- dtype: string
9
- - name: metadata_fn
10
- dtype: string
11
- - name: movie
12
- dtype: string
13
- - name: objects
14
- list: string
15
- - name: width
16
- dtype: int64
17
- - name: height
18
- dtype: int64
19
- - name: image_width
20
- dtype: int64
21
- - name: image_height
22
- dtype: int64
23
- - name: boxes
24
- list:
25
- list: float32
26
- - name: segms_json
27
- dtype: string
28
- - name: question_count
29
- dtype: int64
30
- - name: source_zip_crc_mismatch
31
- dtype: bool
32
- - name: image_metadata_dimension_mismatch
33
- dtype: bool
34
- - name: annotations
35
- list:
36
- - name: movie
37
- dtype: string
38
- - name: objects
39
- list: string
40
- - name: interesting_scores
41
- list: int64
42
- - name: answer_likelihood
43
- dtype: string
44
- - name: img_fn
45
- dtype: string
46
- - name: metadata_fn
47
- dtype: string
48
- - name: answer_orig
49
- dtype: string
50
- - name: question_orig
51
- dtype: string
52
- - name: rationale_orig
53
- dtype: string
54
- - name: question_tokens
55
- list:
56
- - name: kind
57
- dtype: string
58
- - name: text
59
- dtype: string
60
- - name: object_indices
61
- list: int64
62
- - name: answer_choice_tokens
63
- list:
64
- list:
65
- - name: kind
66
- dtype: string
67
- - name: text
68
- dtype: string
69
- - name: object_indices
70
- list: int64
71
- - name: answer_label
72
- dtype: int64
73
- - name: answer_match_iter
74
- list: int64
75
- - name: answer_sources
76
- list: int64
77
- - name: rationale_choice_tokens
78
- list:
79
- list:
80
- - name: kind
81
- dtype: string
82
- - name: text
83
- dtype: string
84
- - name: object_indices
85
- list: int64
86
- - name: rationale_sources
87
- list: int64
88
- - name: rationale_match_iter
89
- list: int64
90
- - name: rationale_label
91
- dtype: int64
92
- - name: source_zip_crc_mismatch
93
- dtype: bool
94
- - name: img_id
95
- dtype: string
96
- - name: question_number
97
- dtype: int64
98
- - name: annot_id
99
- dtype: string
100
- - name: match_fold
101
- dtype: string
102
- - name: match_index
103
- dtype: int64
104
- - name: question_text
105
- dtype: string
106
- - name: answer_choice_texts
107
- list: string
108
- - name: rationale_choice_texts
109
- list: string
110
- splits:
111
- - name: train
112
- num_bytes: 29200718216
113
- num_examples: 80418
114
- - name: validation
115
- num_bytes: 3755841689
116
- num_examples: 9929
117
- - name: test
118
- num_bytes: 3731295388
119
- num_examples: 9557
120
- download_size: 30739927109
121
- dataset_size: 36687855293
122
- - config_name: questions
123
- features:
124
- - name: movie
125
- dtype: string
126
- - name: objects
127
- list: string
128
- - name: interesting_scores
129
- list: int64
130
- - name: answer_likelihood
131
- dtype: string
132
- - name: img_fn
133
- dtype: string
134
- - name: metadata_fn
135
- dtype: string
136
- - name: answer_orig
137
- dtype: string
138
- - name: question_orig
139
- dtype: string
140
- - name: rationale_orig
141
- dtype: string
142
- - name: question_tokens
143
- list:
144
- - name: kind
145
- dtype: string
146
- - name: text
147
- dtype: string
148
- - name: object_indices
149
- list: int64
150
- - name: answer_choice_tokens
151
- list:
152
- list:
153
- - name: kind
154
- dtype: string
155
- - name: text
156
- dtype: string
157
- - name: object_indices
158
- list: int64
159
- - name: answer_label
160
- dtype: int64
161
- - name: answer_match_iter
162
- list: int64
163
- - name: answer_sources
164
- list: int64
165
- - name: rationale_choice_tokens
166
- list:
167
- list:
168
- - name: kind
169
- dtype: string
170
- - name: text
171
- dtype: string
172
- - name: object_indices
173
- list: int64
174
- - name: rationale_sources
175
- list: int64
176
- - name: rationale_match_iter
177
- list: int64
178
- - name: rationale_label
179
- dtype: int64
180
- - name: source_zip_crc_mismatch
181
- dtype: bool
182
- - name: img_id
183
- dtype: string
184
- - name: question_number
185
- dtype: int64
186
- - name: annot_id
187
- dtype: string
188
- - name: match_fold
189
- dtype: string
190
- - name: match_index
191
- dtype: int64
192
- - name: question_text
193
- dtype: string
194
- - name: answer_choice_texts
195
- list: string
196
- - name: rationale_choice_texts
197
- list: string
198
- splits:
199
- - name: train
200
- num_bytes: 772530124
201
- num_examples: 212923
202
- - name: validation
203
- num_bytes: 96810191
204
- num_examples: 26534
205
- - name: test
206
- num_bytes: 83927907
207
- num_examples: 25263
208
- download_size: 760672290
209
- dataset_size: 953268222
210
  configs:
211
  - config_name: image_examples
212
  data_files:
213
  - split: train
214
- path: image_examples/train-*
215
  - split: validation
216
- path: image_examples/validation-*
217
  - split: test
218
- path: image_examples/test-*
 
219
  - config_name: questions
220
  data_files:
221
  - split: train
222
- path: questions/train-*
223
  - split: validation
224
- path: questions/validation-*
225
  - split: test
226
- path: questions/test-*
227
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: other
3
+ pretty_name: "VCR v1.0"
4
+ task_categories:
5
+ - visual-question-answering
6
+ - image-to-text
7
+ tags:
8
+ - image
9
+ - visual-commonsense-reasoning
10
+ - vcr
11
+ - r2c
12
+ - arxiv:1811.10830
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  configs:
14
  - config_name: image_examples
15
  data_files:
16
  - split: train
17
+ path: image_examples/train-*.parquet
18
  - split: validation
19
+ path: image_examples/validation-*.parquet
20
  - split: test
21
+ path: image_examples/test-*.parquet
22
+ default: true
23
  - config_name: questions
24
  data_files:
25
  - split: train
26
+ path: questions/train-*.parquet
27
  - split: validation
28
+ path: questions/validation-*.parquet
29
  - split: test
30
+ path: questions/test-*.parquet
31
  ---
32
+
33
+ # VCR v1.0
34
+
35
+ VCR is the Visual Commonsense Reasoning dataset from "From Recognition to Cognition: Visual Commonsense Reasoning" (CVPR 2019).
36
+
37
+ This Hugging Face version has two loadable configs:
38
+
39
+ - `image_examples`: the default viewer-friendly config, one row per unique image, with grouped annotations.
40
+ - `questions`: one row per original VCR question/answer/rationale example.
41
+
42
+ The original annotation JSONL files are also included under `original_annotations/` for legacy compatibility.
43
+
44
+ ## Source archive note
45
+
46
+ The hosted `vcr1images.zip` object has one JPEG member whose zip CRC does not match, although the member's full byte stream can be recovered and decoded successfully:
47
+
48
+ - `vcr1images/lsmdc_1010_TITANIC/1010_TITANIC_02.33.49.825-02.33.53.701@0.jpg`
49
+
50
+ Rows whose image comes from that zip member have `source_zip_crc_mismatch=true`.
51
+
52
+ The `width` and `height` columns preserve the original metadata JSON dimensions used by boxes/segmentations and by legacy `r2c` code. `image_width` and `image_height` store the decoded JPEG dimensions. Rows where those differ have `image_metadata_dimension_mismatch=true`.
53
+
54
+ ## Legacy r2c layout
55
+
56
+ The original `rowanz/r2c` code expects `train.jsonl`, `val.jsonl`, `test.jsonl`, and a `vcr1images/` directory. Use:
57
+
58
+ ```bash
59
+ python scripts/export_r2c_layout.py <repo_id> /path/to/r2c/data
60
+ ```
61
+
62
+ ## License and terms
63
+
64
+ Use of VCR is governed by the original VCR/AI2 dataset license and website terms:
65
+
66
+ - https://visualcommonsense.com/license/
67
+ - https://visualcommonsense.com/terms/
68
+
69
+ ## Citation
70
+
71
+ ```bibtex
72
+ @inproceedings{zellers2019vcr,
73
+ author = {Zellers, Rowan and Bisk, Yonatan and Farhadi, Ali and Choi, Yejin},
74
+ title = {From Recognition to Cognition: Visual Commonsense Reasoning},
75
+ booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
76
+ month = {June},
77
+ year = {2019}
78
+ }
79
+ ```
80
+
81
+ ## Content warning
82
+
83
+ VCR is annotated from movie images and may contain nudity, violence, offensive content, and biased or problematic depictions.
original_annotations/test.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f59afa1f1fb663d301d3e772dd6d7d9b6b6ab2fb0485345aef9ee07ca439c864
3
+ size 34097024
original_annotations/train.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d911d5c55b1bbf1ac5a6e3f73a9a6e2c2467559463c50c13e74292e0da4ccfaa
3
+ size 392317321
original_annotations/val.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:328478b2f429fd899b0217ad4bcac18e2c017829c43dfcff7cf01d66857a8a01
3
+ size 48969062
scripts/export_r2c_layout.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Export the Hugging Face VCR dataset back to the original r2c layout."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ import json
8
+ import shutil
9
+ from pathlib import Path
10
+
11
+ from datasets import load_dataset, load_from_disk
12
+ from huggingface_hub import hf_hub_download
13
+ from tqdm import tqdm
14
+
15
+
16
+ def main() -> None:
17
+ parser = argparse.ArgumentParser(description=__doc__)
18
+ parser.add_argument("repo_id", help="Hugging Face dataset repo id, e.g. rowanz/vcr")
19
+ parser.add_argument("output_dir", type=Path, help="Directory to create in r2c-compatible layout")
20
+ parser.add_argument("--token", default=None, help="HF token for private/gated repos")
21
+ parser.add_argument("--limit", type=int, default=None, help="Optional per-split row limit for smoke tests")
22
+ parser.add_argument("--local-stage-dir", type=Path, default=None, help="Use a local vcr_hf.py stage directory instead of the Hub")
23
+ args = parser.parse_args()
24
+
25
+ args.output_dir.mkdir(parents=True, exist_ok=True)
26
+ images_dir = args.output_dir / "vcr1images"
27
+ images_dir.mkdir(parents=True, exist_ok=True)
28
+
29
+ for split in ("train", "val", "test"):
30
+ if args.local_stage_dir is None:
31
+ src = hf_hub_download(
32
+ repo_id=args.repo_id,
33
+ repo_type="dataset",
34
+ filename=f"original_annotations/{split}.jsonl",
35
+ token=args.token,
36
+ )
37
+ else:
38
+ src = args.local_stage_dir / "original_annotations" / f"{split}.jsonl"
39
+ dst = args.output_dir / f"{split}.jsonl"
40
+ if args.limit is None:
41
+ shutil.copyfile(src, dst)
42
+ else:
43
+ with open(src, "r", encoding="utf-8") as f_in, open(dst, "w", encoding="utf-8") as f_out:
44
+ for i, line in enumerate(f_in):
45
+ if i >= args.limit:
46
+ break
47
+ f_out.write(line)
48
+
49
+ if args.local_stage_dir is None:
50
+ split_expr = {s: f"{s}[:{args.limit}]" if args.limit is not None else s for s in ("train", "validation", "test")}
51
+ ds = load_dataset(args.repo_id, "image_examples", split=split_expr, token=args.token)
52
+ if not isinstance(ds, dict):
53
+ ds = {"train": ds}
54
+ else:
55
+ local_ds = load_from_disk(args.local_stage_dir / "image_examples.dataset")
56
+ ds = {}
57
+ for split_name in ("train", "validation", "test"):
58
+ ds[split_name] = local_ds[split_name].select(range(min(args.limit, len(local_ds[split_name])))) if args.limit else local_ds[split_name]
59
+
60
+ seen: set[str] = set()
61
+ for split_name, split_ds in ds.items():
62
+ for row in tqdm(split_ds, desc=f"export {split_name} images"):
63
+ img_fn = row["img_fn"]
64
+ metadata_fn = row["metadata_fn"]
65
+
66
+ if img_fn not in seen:
67
+ image = row["image"]
68
+ dst_img = images_dir / img_fn
69
+ dst_img.parent.mkdir(parents=True, exist_ok=True)
70
+ image.save(dst_img)
71
+ seen.add(img_fn)
72
+
73
+ if metadata_fn not in seen:
74
+ metadata = {
75
+ "boxes": row["boxes"],
76
+ "segms": json.loads(row["segms_json"]),
77
+ "names": row["objects"],
78
+ "width": row["width"],
79
+ "height": row["height"],
80
+ }
81
+ dst_meta = images_dir / metadata_fn
82
+ dst_meta.parent.mkdir(parents=True, exist_ok=True)
83
+ with open(dst_meta, "w", encoding="utf-8") as f:
84
+ json.dump(metadata, f, separators=(",", ":"))
85
+ seen.add(metadata_fn)
86
+
87
+ print(f"Wrote r2c-compatible VCR layout to {args.output_dir}")
88
+
89
+
90
+ if __name__ == "__main__":
91
+ main()