Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -10,7 +10,8 @@ viewer: false
|
|
| 10 |
|
| 11 |
# Multi-Drive World Model Data
|
| 12 |
|
| 13 |
-
Action-conditioned driving gameplay from multiple racing games, grouped by visual theme, for
|
|
|
|
| 14 |
|
| 15 |
| theme | source games | clips | frames |
|
| 16 |
|---|---|---|---|
|
|
@@ -18,9 +19,104 @@ Action-conditioned driving gameplay from multiple racing games, grouped by visua
|
|
| 18 |
| realistic | forza-horizon, need-for-speed | 27 | 340,722 |
|
| 19 |
| arcade | asphalt-9 | 10 | 142,966 |
|
| 20 |
|
| 21 |
-
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# Multi-Drive World Model Data
|
| 12 |
|
| 13 |
+
Action-conditioned driving gameplay from multiple racing games, grouped by visual **theme**, for
|
| 14 |
+
training a single multi-game world model. 1,073,248 frames across 155 clips.
|
| 15 |
|
| 16 |
| theme | source games | clips | frames |
|
| 17 |
|---|---|---|---|
|
|
|
|
| 19 |
| realistic | forza-horizon, need-for-speed | 27 | 340,722 |
|
| 20 |
| arcade | asphalt-9 | 10 | 142,966 |
|
| 21 |
|
| 22 |
+
- **Frames:** 384x216 RGB JPEG.
|
| 23 |
+
- **`metadata.jsonl`:** one line per clip — `{clip, theme, game, n_frames, path}`.
|
| 24 |
|
| 25 |
+
## Why tar files (and why the dataset viewer is off)
|
| 26 |
+
|
| 27 |
+
The `.tar` files are **not a WebDataset**. Each tar holds ordered directories, one per contiguous
|
| 28 |
+
gameplay run:
|
| 29 |
+
|
| 30 |
+
```
|
| 31 |
+
<run>/frames/frame_000000.jpg
|
| 32 |
+
<run>/frames/frame_000001.jpg
|
| 33 |
+
...
|
| 34 |
+
<run>/actions.jsonl # one JSON line per frame, same order as the frames
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
Three reasons for this layout:
|
| 38 |
+
|
| 39 |
+
1. **A world model trains on contiguous sequences, not independent samples.** The unit of training
|
| 40 |
+
is a window of N consecutive frames plus the actions taken across them. WebDataset's flat
|
| 41 |
+
`key.jpg` / `key.json` pairing has no way to express "these frames are consecutive and ordered",
|
| 42 |
+
and the viewer would shuffle them — which is meaningless for video.
|
| 43 |
+
2. **File count.** Stored as loose files this would be millions of objects in one repo, which makes
|
| 44 |
+
listing, cloning and LFS painful. Tars keep it to a few hundred objects.
|
| 45 |
+
3. **Sequential reads.** Training reads neighbouring frames together; a tar keeps them adjacent
|
| 46 |
+
rather than scattered across a bucket.
|
| 47 |
+
|
| 48 |
+
Because the layout is deliberately not WebDataset, HF's auto-detection cannot parse it and the
|
| 49 |
+
dataset viewer is disabled (`viewer: false`). Load the tars directly with the snippets below.
|
| 50 |
+
|
| 51 |
+
## Loading
|
| 52 |
+
|
| 53 |
+
```python
|
| 54 |
+
import json, tarfile, glob, os
|
| 55 |
+
from huggingface_hub import hf_hub_download
|
| 56 |
+
|
| 57 |
+
REPO = "codelion/multi-drive-model-data"
|
| 58 |
+
|
| 59 |
+
# the index: one line per run -> pick what you want without downloading everything
|
| 60 |
+
meta = [json.loads(l) for l in
|
| 61 |
+
open(hf_hub_download(REPO, "metadata.jsonl", repo_type="dataset")) if l.strip()]
|
| 62 |
+
print(len(meta), "runs")
|
| 63 |
+
|
| 64 |
+
# fetch and unpack one tar
|
| 65 |
+
tar = hf_hub_download(REPO, meta[0]["path"] if "path" in meta[0]
|
| 66 |
+
else f"data/{meta[0]['shard']}.tar", repo_type="dataset")
|
| 67 |
+
with tarfile.open(tar) as tf:
|
| 68 |
+
tf.extractall("work")
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
Each tar unpacks to a single `<clip>/` directory.
|
| 72 |
+
|
| 73 |
+
## Building training sequences
|
| 74 |
+
|
| 75 |
+
Frames and action records are index-aligned, so a training window is just a slice:
|
| 76 |
+
|
| 77 |
+
```python
|
| 78 |
+
import numpy as np
|
| 79 |
+
from PIL import Image
|
| 80 |
+
|
| 81 |
+
def load_run(run_dir):
|
| 82 |
+
frames = sorted(glob.glob(os.path.join(run_dir, "frames", "*.jpg")))
|
| 83 |
+
recs = [json.loads(l) for l in open(os.path.join(run_dir, "actions.jsonl")) if l.strip()]
|
| 84 |
+
n = min(len(frames), len(recs)) # always slice to the shorter of the two
|
| 85 |
+
actions = np.array([r["actions"] for r in recs[:n]], np.float32) # [n, 7]
|
| 86 |
+
return frames[:n], actions
|
| 87 |
+
|
| 88 |
+
def windows(frames, actions, seq_len=16, stride=8):
|
| 89 |
+
"""contiguous (frames, actions) windows — the unit a world model trains on"""
|
| 90 |
+
for s in range(0, len(frames) - seq_len + 1, stride):
|
| 91 |
+
imgs = np.stack([np.asarray(Image.open(f).convert("RGB"), np.float32) / 255.0
|
| 92 |
+
for f in frames[s:s + seq_len]]) # [seq,H,W,3]
|
| 93 |
+
yield imgs, actions[s:s + seq_len] # [seq,7]
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
Themes are the conditioning label used by the model (game names stay in the metadata).
|
| 97 |
+
|
| 98 |
+
## Actions (7-dim)
|
| 99 |
+
|
| 100 |
+
| idx | field | type | notes |
|
| 101 |
+
|---|---|---|---|
|
| 102 |
+
| 0-4 | `accel, brake, left, right, drift` | binary | key presses = the player's *intent* |
|
| 103 |
+
| 5 | `speed` | float [-1,1] | measured forward expansion, **negative when reversing** |
|
| 104 |
+
| 6 | `turn_rate` | float [-1,1] | measured horizontal flow |
|
| 105 |
+
|
| 106 |
+
Indices 0-4 are what the player pressed; 5-6 measure what the world actually did (optical flow).
|
| 107 |
+
Both are included deliberately: key presses alone are a weak conditioning signal here, because
|
| 108 |
+
`accel` is held in 73-88% of frames — a near-constant bit carries almost no information, and a
|
| 109 |
+
model trained on it alone ignores the throttle entirely.
|
| 110 |
+
|
| 111 |
+
Normalisation: `speed /= 1.266`, `turn_rate /= 1.559` (p95 of |value|), then clipped to [-1,1].
|
| 112 |
+
Note `turn_rate` is a *measurement*, so it lags the key press by ~6 frames (~0.4 s) — the car's
|
| 113 |
+
visual response to steering, not the input event.
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
## Curation
|
| 117 |
+
|
| 118 |
+
1. Gameplay-only filtering of commercial-game screen recordings: a CLIP content classifier removes
|
| 119 |
+
menus, car-select, results/reward screens, loading, and non-game content (browsers, streams)
|
| 120 |
+
present in the source captures; near-static frames are dropped by a motion floor. ~45% of the
|
| 121 |
+
raw recordings were not gameplay.
|
| 122 |
+
2. Ego-motion measured per frame with optical flow and appended to the action vector.
|