May-apple commited on
Commit
accb95e
·
verified ·
1 Parent(s): d748875

docs: rewrite 'How to use' for parquet-shipped repo (schema, Path A direct read, Path B extract to dir)

Browse files
Files changed (1) hide show
  1. README.md +144 -6
README.md CHANGED
@@ -205,19 +205,157 @@ of every rewritten task.
205
 
206
  ## How to use this dataset
207
 
208
- ### Loading via Hugging Face Datasets
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
 
210
  ```python
211
  from datasets import load_dataset
212
 
213
- # Full dataset (uses metadata.jsonl files at each split)
214
- ds = load_dataset("Video-Reason/VBVR-Reorganized", split="train")
215
- # or per-split:
216
- # "train", "test_in_domain", "test_out_of_domain"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
 
218
- # Each row exposes: split, class, task, sample_idx, prompt, first_frame, final_frame, ground_truth_video, metadata_json
 
 
 
 
 
 
 
219
  ```
220
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  ### Local browsing (small viewable subset)
222
 
223
  For a 3-samples-per-generator view (612 samples, ~2GB), see the
 
205
 
206
  ## How to use this dataset
207
 
208
+ > **The HF repo ships parquet shards, not the directory tree above.** The
209
+ > `Layout` section describes the *conceptual* organization. On Hub, every
210
+ > sample is one parquet row with media bytes (`first_frame.png`,
211
+ > `final_frame.png`, `ground_truth.mp4`) embedded inline. You have two
212
+ > options: read the parquet directly (Path A), or materialize the parquet
213
+ > back into the directory layout (Path B).
214
+
215
+ ### Parquet row schema (all splits)
216
+
217
+ Every parquet shard under `parquet/` shares the same row schema:
218
+
219
+ | Column | Type | Notes |
220
+ |---------------------|---------------------------------------------|----------------------------------------------------------------|
221
+ | `class` | string | `Pure_Reasoning` or `Instruction_Following` |
222
+ | `task` | string | e.g. `G-13_grid_number_sequence_data-generator` |
223
+ | `split` | string | e.g. `train`, `test/In-Domain_50`, `train_pr_rewritten` |
224
+ | `sample_id` | string | per-task relative path (for train rows includes the wrapper) |
225
+ | `prompt` | string | the prompt to feed to the model |
226
+ | `prompt_original` | string \| null | only for PR-rewrite tasks (see "How prompt rewrites work") |
227
+ | `first_frame` | `{bytes: binary, path: string}` (HF Image) | PNG bytes of the input frame |
228
+ | `final_frame` | `{bytes: binary, path: string}` (HF Image) | PNG bytes of the target final frame |
229
+ | `ground_truth_video`| `{bytes: binary, path: string}` (HF Video) | MP4 bytes of the target video |
230
+ | `metadata_json` | string | raw text of the per-sample `metadata.json` |
231
+
232
+ Available splits / parquet shards:
233
+
234
+ | Logical split | Parquet path |
235
+ |-------------------------|-----------------------------------------|
236
+ | `train` | `parquet/train__*.parquet` (one shard per train task) |
237
+ | `test_in_domain` | `parquet/test_in_domain.parquet` |
238
+ | `test_out_of_domain` | `parquet/test_out_of_domain.parquet` |
239
+ | `train_pr_rewritten` | `parquet/train_pr_rewritten.parquet` |
240
+ | `train_pr_unchanged` | `parquet/train_pr_unchanged.parquet` |
241
+
242
+ ### Path A — read parquet rows directly (recommended)
243
+
244
+ The HF `datasets` library auto-decodes `first_frame` / `final_frame` into
245
+ `PIL.Image` and `ground_truth_video` into a `decord`/`VideoReader`-style
246
+ object:
247
 
248
  ```python
249
  from datasets import load_dataset
250
 
251
+ # Load any single split. Shards under parquet/train__*.parquet are merged
252
+ # into one logical "train" split via the YAML config above.
253
+ ds = load_dataset("May-apple/VBVR-Reorganized", split="test_in_domain")
254
+ # other splits: "train", "test_out_of_domain", "train_pr_rewritten", "train_pr_unchanged"
255
+
256
+ row = ds[0]
257
+ print(row["prompt"]) # str
258
+ print(row["class"], row["task"])
259
+ row["first_frame"].save("first.png") # PIL.Image
260
+ row["final_frame"].save("final.png")
261
+ # ground_truth_video is a `datasets.Video` object; underlying bytes are in
262
+ # row["ground_truth_video"]["bytes"] if you bypass auto-decoding (see below).
263
+ ```
264
+
265
+ If you only want the **prompts / metadata** and don't need to decode the
266
+ heavy media (much faster, no PIL/decord needed), bypass HF's feature
267
+ decoding and read the raw parquet with `pyarrow` / `pandas`:
268
+
269
+ ```python
270
+ import pyarrow.parquet as pq
271
+
272
+ t = pq.read_table("parquet/test_in_domain.parquet",
273
+ columns=["class", "task", "split", "sample_id",
274
+ "prompt", "prompt_original", "metadata_json"])
275
+ df = t.to_pandas()
276
+ print(df.head())
277
+ ```
278
+
279
+ To pull the **raw bytes** of one media field for a single row:
280
+
281
+ ```python
282
+ import pyarrow.parquet as pq
283
+
284
+ pf = pq.ParquetFile("parquet/test_in_domain.parquet")
285
+ row = pf.read_row_group(0).to_pylist()[0]
286
+ open("first_frame.png", "wb").write(row["first_frame"]["bytes"])
287
+ open("final_frame.png", "wb").write(row["final_frame"]["bytes"])
288
+ open("ground_truth.mp4", "wb").write(row["ground_truth_video"]["bytes"])
289
+ ```
290
 
291
+ To load only **one train task** (without pulling the whole 1M-row
292
+ training set), just load that task's parquet shard by filename:
293
+
294
+ ```python
295
+ from datasets import load_dataset
296
+ ds = load_dataset("parquet",
297
+ data_files="parquet/train__G-13_grid_number_sequence.parquet",
298
+ split="train")
299
  ```
300
 
301
+ ### Path B — materialize parquet → on-disk directory layout
302
+
303
+ If your existing pipeline reads `first_frame.png` / `ground_truth.mp4` /
304
+ `prompt.txt` from a directory tree, this repo ships an extractor script
305
+ (`extract_parquet_to_dir.py`, in the repo root) that streams a parquet
306
+ shard and writes one directory per row, reproducing exactly the "Layout"
307
+ tree at the top of this card:
308
+
309
+ ```bash
310
+ # Step 1 — download just the parquet you care about (plus the script):
311
+ # the test splits + the script (~100 MB total)
312
+ hf download May-apple/VBVR-Reorganized \
313
+ --repo-type dataset \
314
+ --include "parquet/test_*.parquet" "extract_parquet_to_dir.py" \
315
+ --local-dir ./VBVR-Reorganized
316
+
317
+ # (Or use `git clone https://huggingface.co/datasets/May-apple/VBVR-Reorganized`
318
+ # for the whole repo. Requires git-lfs.)
319
+
320
+ cd ./VBVR-Reorganized
321
+
322
+ # Step 2 — materialize a single parquet shard into ./extracted/
323
+ python3 extract_parquet_to_dir.py \
324
+ --parquet parquet/test_in_domain.parquet \
325
+ --out ./extracted
326
+
327
+ # Or extract every parquet at once
328
+ python3 extract_parquet_to_dir.py \
329
+ --parquet parquet/ \
330
+ --out ./extracted
331
+
332
+ # Or filter to one task (useful for the multi-GB train shards)
333
+ python3 extract_parquet_to_dir.py \
334
+ --parquet parquet/train__G-13_grid_number_sequence.parquet \
335
+ --out ./extracted \
336
+ --task G-13_grid_number_sequence_data-generator
337
+ ```
338
+
339
+ Only dependency: `pyarrow` (`pip install pyarrow`).
340
+
341
+ Output tree:
342
+
343
+ ```
344
+ VBVR-extracted/
345
+ └── <split>/<class>/<task>/<sample_id>/
346
+ ├── first_frame.png
347
+ ├── final_frame.png
348
+ ├── ground_truth.mp4
349
+ ├── prompt.txt
350
+ ├── prompt_original.txt (only for PR-rewrite tasks)
351
+ └── metadata.json
352
+ ```
353
+
354
+ The script reads one parquet row-group at a time, so it works on the
355
+ multi-GB train shards without loading the whole file into memory. The
356
+ script body is short (<150 lines, pure stdlib + `pyarrow`) — copy it
357
+ directly if you don't have access to the source repo.
358
+
359
  ### Local browsing (small viewable subset)
360
 
361
  For a 3-samples-per-generator view (612 samples, ~2GB), see the