--- license: other pretty_name: Multi-Drive World Model Data tags: - world-model - driving - video-games viewer: false --- # Multi-Drive World Model Data Action-conditioned driving gameplay from multiple racing games, grouped by visual **theme**, for training a single multi-game world model. 1,073,248 frames across 155 clips. | theme | source games | clips | frames | |---|---|---|---| | cartoon | supertuxkart | 118 | 589,560 | | realistic | forza-horizon, need-for-speed | 27 | 340,722 | | arcade | asphalt-9 | 10 | 142,966 | - **Frames:** 384x216 RGB JPEG. - **`metadata.jsonl`:** one line per clip — `{clip, theme, game, n_frames, path}`. ## Why tar files (and why the dataset viewer is off) The `.tar` files are **not a WebDataset**. Each tar holds ordered directories, one per contiguous gameplay run: ``` /frames/frame_000000.jpg /frames/frame_000001.jpg ... /actions.jsonl # one JSON line per frame, same order as the frames ``` Three reasons for this layout: 1. **A world model trains on contiguous sequences, not independent samples.** The unit of training is a window of N consecutive frames plus the actions taken across them. WebDataset's flat `key.jpg` / `key.json` pairing has no way to express "these frames are consecutive and ordered", and the viewer would shuffle them — which is meaningless for video. 2. **File count.** Stored as loose files this would be millions of objects in one repo, which makes listing, cloning and LFS painful. Tars keep it to a few hundred objects. 3. **Sequential reads.** Training reads neighbouring frames together; a tar keeps them adjacent rather than scattered across a bucket. Because the layout is deliberately not WebDataset, HF's auto-detection cannot parse it and the dataset viewer is disabled (`viewer: false`). Load the tars directly with the snippets below. ## Loading ```python import json, tarfile, glob, os from huggingface_hub import hf_hub_download REPO = "codelion/multi-drive-model-data" # the index: one line per run -> pick what you want without downloading everything meta = [json.loads(l) for l in open(hf_hub_download(REPO, "metadata.jsonl", repo_type="dataset")) if l.strip()] print(len(meta), "runs") # fetch and unpack one tar tar = hf_hub_download(REPO, meta[0]["path"] if "path" in meta[0] else f"data/{meta[0]['shard']}.tar", repo_type="dataset") with tarfile.open(tar) as tf: tf.extractall("work") ``` Each tar unpacks to a single `/` directory. ## Building training sequences Frames and action records are index-aligned, so a training window is just a slice: ```python import numpy as np from PIL import Image def load_run(run_dir): frames = sorted(glob.glob(os.path.join(run_dir, "frames", "*.jpg"))) recs = [json.loads(l) for l in open(os.path.join(run_dir, "actions.jsonl")) if l.strip()] n = min(len(frames), len(recs)) # always slice to the shorter of the two actions = np.array([r["actions"] for r in recs[:n]], np.float32) # [n, 7] return frames[:n], actions def windows(frames, actions, seq_len=16, stride=8): """contiguous (frames, actions) windows — the unit a world model trains on""" for s in range(0, len(frames) - seq_len + 1, stride): imgs = np.stack([np.asarray(Image.open(f).convert("RGB"), np.float32) / 255.0 for f in frames[s:s + seq_len]]) # [seq,H,W,3] yield imgs, actions[s:s + seq_len] # [seq,7] ``` Themes are the conditioning label used by the model (game names stay in the metadata). ## Actions (7-dim) | idx | field | type | notes | |---|---|---|---| | 0-4 | `accel, brake, left, right, drift` | binary | key presses = the player's *intent* | | 5 | `speed` | float [-1,1] | measured forward expansion, **negative when reversing** | | 6 | `turn_rate` | float [-1,1] | measured horizontal flow | Indices 0-4 are what the player pressed; 5-6 measure what the world actually did (optical flow). Both are included deliberately: key presses alone are a weak conditioning signal here, because `accel` is held in 73-88% of frames — a near-constant bit carries almost no information, and a model trained on it alone ignores the throttle entirely. Normalisation: `speed /= 1.266`, `turn_rate /= 1.559` (p95 of |value|), then clipped to [-1,1]. Note `turn_rate` is a *measurement*, so it lags the key press by ~6 frames (~0.4 s) — the car's visual response to steering, not the input event. ## Curation 1. Gameplay-only filtering of commercial-game screen recordings: a CLIP content classifier removes menus, car-select, results/reward screens, loading, and non-game content (browsers, streams) present in the source captures; near-static frames are dropped by a motion floor. ~45% of the raw recordings were not gameplay. 2. Ego-motion measured per frame with optical flow and appended to the action vector.