Datasets:
|
Download README.md from jimchen2/bouncing-balls: direct link, hf CLI and curl.
- Browser
- Download file 5.2 kB
-
https://huggingface.co/datasets/jimchen2/bouncing-balls/resolve/main/README.md
- Command line
-
hf download hf://datasets/jimchen2/bouncing-balls/README.md
-
curl -L -o README.md https://huggingface.co/datasets/jimchen2/bouncing-balls/resolve/main/README.md
5.2 kB
| license: mit | |
| pretty_name: Bouncing Balls | |
| task_categories: | |
| - video-classification | |
| tags: | |
| - synthetic | |
| - video | |
| - bouncing-balls | |
| - physics | |
| - colorful | |
| - multi-object | |
| - collision | |
| - webdataset | |
| size_categories: | |
| - 1K<n<10K | |
| configs: | |
| - config_name: default | |
| data_files: | |
| - split: train | |
| path: data/train-*.parquet | |
| # Bouncing Balls | |
| A synthetic dataset of **3,000 videos**, each showing **3–5 smaller, differently colored balls** bouncing around a square. | |
| ## Dataset summary | |
| - **Videos:** 3,000 MP4 clips | |
| - **Balls per video:** 3, 4, or 5 | |
| - **Total ball instances:** 12,087 | |
| - **Ball radius:** 7–12 pixels | |
| - **Resolution:** **196 × 196 pixels** | |
| - **Duration:** 24 frames at 12 fps (2 seconds per clip) | |
| - **Motion:** straight-line movement, wall bounces, and elastic ball-to-ball collisions | |
| - **Parquet:** 10 shards with 300 videos per shard | |
| - **WebDataset:** 9 train shards (2,700 videos) and 3 validation shards (300 videos) | |
| - **Generation seed:** 42 | |
| - **Raw MP4 size:** approximately 26.3 MiB | |
| - **Parquet size:** approximately 26.8 MiB | |
| - **WebDataset size:** approximately 31.5 MiB | |
| - **Complete dataset size:** approximately 86.8 MiB | |
| Ball colors are sampled in HSV space to keep them bright and saturated. Hues are spaced within each video to make the balls visually distinct. Initial positions are sampled without overlap. | |
| ## Folder structure | |
| ```text | |
| . | |
| ├── data/ # Parquet version (all 3,000 videos) | |
| │ ├── train-00000-of-00010.parquet | |
| │ ├── ... | |
| │ └── train-00009-of-00010.parquet | |
| ├── videos/ # Original MP4 files | |
| │ ├── 000000.mp4 | |
| │ ├── ... | |
| │ └── 002999.mp4 | |
| ├── wds/ # WebDataset version | |
| │ ├── train/ # 2,700 videos: 000000–002699 | |
| │ │ ├── bouncing-balls-train-000000.tar | |
| │ │ ├── ... | |
| │ │ └── bouncing-balls-train-000008.tar | |
| │ └── val/ # 300 videos: 002700–002999 | |
| │ ├── bouncing-balls-val-000000.tar | |
| │ ├── ... | |
| │ └── bouncing-balls-val-000002.tar | |
| ├── metadata.jsonl # One metadata record per raw MP4 | |
| └── scripts/ | |
| ├── generate_bouncing_balls.py | |
| ├── shard_bouncing_balls.py # Parquet sharding | |
| ├── shard_bouncing_balls_wds.py # WebDataset sharding | |
| └── requirements.txt | |
| ``` | |
| The Parquet shards are self-contained: MP4 bytes and metadata are embedded together. The original MP4 files are also included under `videos/` for direct use. `metadata.jsonl` contains one record per raw video, keyed by `file_name`. | |
| ## WebDataset shards | |
| The `wds/` directory contains uncompressed WebDataset `.tar` archives: | |
| | Split | Tar files | Videos | Videos per shard | Video keys | | |
| |---|---:|---:|---:|---| | |
| | train | 9 | 2,700 | 300 | `000000`–`002699` | | |
| | val | 3 | 300 | 100 | `002700`–`002999` | | |
| Each tar member is named `<key>.mp4`, for example `000000.mp4`. Metadata is not duplicated inside the tar files; use `metadata.jsonl` or the Parquet version for the ball annotations. | |
| For a VideoSAUR-style configuration, the shard patterns are: | |
| ```text | |
| dataset.train_shards=/path/to/bouncing-balls/wds/train/bouncing-balls-train-{000000..000008}.tar | |
| dataset.val_shards=/path/to/bouncing-balls/wds/val/bouncing-balls-val-{000000..000002}.tar | |
| ``` | |
| With the Python `webdataset` package: | |
| ```python | |
| import webdataset as wds | |
| train = wds.WebDataset( | |
| "wds/train/bouncing-balls-train-{000000..000008}.tar" | |
| ) | |
| val = wds.WebDataset( | |
| "wds/val/bouncing-balls-val-{000000..000002}.tar" | |
| ) | |
| ``` | |
| ## Columns | |
| | Column | Description | | |
| |---|---| | |
| | `video` | The MP4 video clip, stored as embedded bytes in Parquet | | |
| | `num_balls` | Number of balls in the clip (3, 4, or 5) | | |
| | `colors` | Color names for the balls | | |
| | `background_rgb` | Background color as an RGB triplet | | |
| | `balls` | Per-ball color, RGB, radius, initial position, and initial velocity | | |
| | `num_frames` | Number of frames (24) | | |
| | `fps` | Frames per second (12) | | |
| | `width` | Frame width (196) | | |
| | `height` | Frame height (196) | | |
| Each entry in `balls` has: | |
| ```text | |
| color: string | |
| color_rgb: [int, int, int] | |
| radius: int | |
| initial_position: [x, y] | |
| initial_velocity: [vx, vy] | |
| ``` | |
| ## Usage | |
| ```python | |
| from datasets import load_dataset | |
| ds = load_dataset("jimchen2/bouncing-balls", split="train") | |
| print(ds) | |
| print(ds[0]["num_balls"]) | |
| print(ds[0]["balls"]) | |
| ``` | |
| Decoding videos with `datasets` may require `torchcodec`. | |
| ## Reproduce | |
| ```bash | |
| pip install -r scripts/requirements.txt | |
| # Generate the raw videos and metadata | |
| python scripts/generate_bouncing_balls.py \ | |
| --count 3000 \ | |
| --output bouncing-balls | |
| # Create Parquet shards | |
| python scripts/shard_bouncing_balls.py \ | |
| --source bouncing-balls \ | |
| --output sharded \ | |
| --shards 10 | |
| # Create WebDataset train/val tar shards | |
| python scripts/shard_bouncing_balls_wds.py \ | |
| --source bouncing-balls \ | |
| --output bouncing-balls/wds | |
| ``` | |
| ## License | |
| MIT. The videos are synthetically generated and may be used for experimentation, education, and model development. | |