|
Download docs/LOADING.md from deepdeltalab/CausalCascade: direct link, hf CLI and curl.
- Browser
- Download file 2.63 kB
-
https://huggingface.co/datasets/deepdeltalab/CausalCascade/resolve/main/docs/LOADING.md
- Command line
-
hf download hf://datasets/deepdeltalab/CausalCascade/docs/LOADING.md
-
curl -L -o LOADING.md https://huggingface.co/datasets/deepdeltalab/CausalCascade/resolve/main/docs/LOADING.md
2.63 kB
| # Loading | |
| ## Hugging Face metadata | |
| ```python | |
| from datasets import load_dataset | |
| repo = "deepdeltalab/CausalCascade" | |
| rq2 = load_dataset(repo, "rq2_pairs", split="test") | |
| print(rq2.select_columns("counterfactual_reference_video_path")[0]) | |
| ``` | |
| The `base_scenes` and `rq2_pairs` viewers display native `Image` and `Video` | |
| columns. The `counterfactuals` viewer contains metadata and media paths. | |
| Image bytes are | |
| embedded in Parquet; video columns reference MP4 files in this repository | |
| using `hf://datasets/deepdeltalab/CausalCascade@main/` URIs. | |
| The separate `*_path` columns remain repository-relative strings. | |
| To inspect metadata without decoding native media: | |
| ```python | |
| rq2_metadata = rq2.remove_columns([ | |
| "factual_initial_frame", "counterfactual_initial_frame", | |
| "factual_reference_video", "counterfactual_reference_video", | |
| ]) | |
| ``` | |
| Native video decoding through `datasets` requires its compatible TorchCodec | |
| dependencies. The wrapper below uses OpenCV and removes the viewer columns | |
| before reading rows, so it retains its existing lazy-loading behavior. | |
| ## Lazy PyTorch loading | |
| Clone the dataset repository and install its lightweight wrapper: | |
| ```bash | |
| pip install -e ".[video]" | |
| ``` | |
| ```python | |
| from torch.utils.data import DataLoader | |
| from causalcascade import CausalCascadeDataset, collate_fn | |
| dataset = CausalCascadeDataset( | |
| repo_id="deepdeltalab/CausalCascade", | |
| subset="rq2_pairs", | |
| split="test", | |
| decode_images=True, | |
| decode_video=True, | |
| video_size=(480, 854), # (height, width) | |
| video_frame_stride=2, | |
| load_annotations=True, | |
| ) | |
| loader = DataLoader(dataset, batch_size=1, num_workers=4, collate_fn=collate_fn) | |
| for batch in loader: | |
| factual_video = batch["factual_reference_video"] | |
| counterfactual_video = batch["counterfactual_reference_video"] | |
| break | |
| ``` | |
| Videos are decoded only inside `__getitem__`. `video_size`, `video_frame_stride`, and `video_max_frames` control memory use without changing the stored reference videos. Because videos may have different lengths, `collate_fn` stacks equal-shaped tensors and otherwise returns a list. Set `decode_video=False` to keep path strings without downloading videos. | |
| The example's resizing and frame stride are loading conveniences, not the evaluation protocol. Use the complete stored rollouts and the companion metric code for official motion evaluation. For RQ2, use the matched Level 1 prompts and both factual/counterfactual references in each row; an edit instruction describes the intervention and is not a replacement generation prompt. | |
| For a local checkout, replace `repo_id` with `local_root="/path/to/CausalCascade"`. | |