codelion commited on
Commit
fd8fbe8
·
verified ·
1 Parent(s): 283825a

audit: README.md

Browse files
Files changed (1) hide show
  1. README.md +155 -69
README.md CHANGED
@@ -5,118 +5,204 @@ tags:
5
  - world-model
6
  - driving
7
  - video-games
 
8
  viewer: false
9
  ---
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
- |---|---|---|---|
18
- | cartoon | supertuxkart | 118 | 589,560 |
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.
 
5
  - world-model
6
  - driving
7
  - video-games
8
+ - action-conditioned
9
  viewer: false
10
  ---
11
 
12
  # Multi-Drive World Model Data
13
 
14
+ Action-conditioned driving gameplay from four racing games, grouped by visual **theme**, for training
15
+ a single multi-game world model. **1,073,285 frames** across **153 usable clips** at 384x216.
16
 
17
+ | theme | source games | clips | frames | mean \|r\| (label vs motion) |
18
+ |---|---|---|---|---|
19
+ | cartoon | supertuxkart | 118 | 589,560 | 0.828 |
20
+ | realistic | forza-horizon, need-for-speed | 25 | 340,722 | 0.782 |
21
+ | arcade | asphalt-9 | 10 | 142,966 | 0.805 |
22
+
23
+ Every clip has been re-labelled and independently verified — see **Label alignment** below, which is
24
+ the main reason to prefer this over the original release.
25
+
26
+ ## Actions (7-dim)
27
+
28
+ **These are not recorded key presses.** The source is screen recordings of commercial games, so no
29
+ controller ground truth exists. Every channel is derived from optical flow between consecutive
30
+ frames. Treat indices 0–3 as *inferred* intent, not as a log of what the player pressed.
31
+
32
+ | idx | field | type | ON-rate / range | notes |
33
+ |---|---|---|---|---|
34
+ | 0 | `accel` | binary | 14.9% | from the **change** in speed, not its level |
35
+ | 1 | `brake` | binary | 15.1% | negative speed change |
36
+ | 2 | `left` | binary | 21.4% | `turn` above a per-clip percentile |
37
+ | 3 | `right` | binary | 18.6% | `turn` below it |
38
+ | 4 | `drift` | binary | **0.0% — always zero** | dead channel, see below |
39
+ | 5 | `speed` | float | mean +0.311, p5 −0.39, p95 +0.99 | signed forward expansion, negative when reversing |
40
+ | 6 | `turn` | float | mean +0.023, p5 −0.82, p95 +0.87 | horizontal flow |
41
+
42
+ Each record is `{frame_file, actions, dup}`. `dup` marks a near-duplicate of the previous frame
43
+ (1.2% of frames — engine stutter in the source capture); dropping those windows is reasonable.
44
+
45
+ **`drift` is identically zero in every frame.** The re-labelling pass had no flow signature that
46
+ reliably distinguishes a drift, so rather than emit a guess it writes a constant. Use 6 channels, or
47
+ expect index 4 to contribute nothing.
48
+
49
+ **Why `accel` comes from the change in speed.** These games auto-accelerate. In the original labels
50
+ the throttle bit was on in 73–88% of frames, which is nearly a constant, and a model conditioned on
51
+ it learns to ignore the throttle entirely. Differencing gives a bit that actually varies.
52
+
53
+ Normalisation is **per clip**: `speed` and `turn` are divided by that clip's own p95 of `|value|`
54
+ and clipped to [−1, 1]. Absolute speeds are therefore not comparable between clips — a "1.0" in a
55
+ slow kart clip and in a Forza clip are different real speeds.
56
+
57
+ ## Label alignment (the reason this release exists)
58
+
59
+ Labels are attached to the transition `(i−1 → i)`, so `actions[i]` describes how the world got to
60
+ `frames[i]` — which is what an action-conditioned model conditions on to predict frame `i`.
61
 
62
+ The original labels did not do this. Steering correlated with horizontal flow best at lag **+2**
63
+ (cartoon), **+3** (arcade) and **+6** (realistic) instead of 0, even though they had been extracted
64
+ from optical flow in the first place. In `realistic` this left steering essentially dead (r ≈ 0.05).
65
 
66
+ Re-derived labels were validated as a **gate**, not a report: a clip whose new labels failed the
67
+ correlation check kept its original actions and is flagged, rather than being silently replaced with
68
+ something worse. Per-run results are in `labelqc.json` inside each tar.
69
 
70
+ Verified by `wm/dataset_audit.py` on **all 153 clips**, using optical flow recomputed at a different
71
+ scale than the labeller used, so it is an independent measurement and not a restatement:
72
 
73
  ```
74
+ best lag == 0 153 / 153 clips (100%)
75
+ mean |r| at lag 0 0.819
76
+ worst clip 0.673
 
77
  ```
78
 
79
+ ## Integrity
80
+
81
+ Full pass over every run and every frame:
82
 
83
+ ```
84
+ unreadable runs 2 (empty tars — see note below)
85
+ corrupt/truncated JPEG 0 (checked for the FFD9 end-of-image marker on all 1,073,285 files)
86
+ frame/action mismatch 0
87
+ frame_file mismatch 0
88
+ NaN / out-of-range 0
89
+ non-binary key bits 0
90
+ ```
91
 
92
+ `md_integrity.jsonl` has one row per run. `md_quality_all.jsonl` ranks every clip; see below.
 
93
 
94
+ Two tars in `data/realistic/` contain an `actions.jsonl` and no frames at all. They are honestly
95
+ declared as `n_frames: 0` in `metadata.jsonl` and are still present rather than deleted, so
96
+ **filter on `n_frames > 0`** (or on membership in `md_quality_all.jsonl`, which excludes them):
97
+
98
+ ```
99
+ data/realistic/forza-horizon__78c15140-4eae-48e7-ba0a-6aba108182d2.tar
100
+ data/realistic/need-for-speed__30b4c31f-cb43-4717-88c3-847d032cd436.tar
101
+ ```
102
+
103
+ ## Choosing what to train on
104
+
105
+ `md_quality_*.jsonl` rank clips by measured training value, so you can take the good half instead of
106
+ all of it. Six rank-normalised measures: `control` (does the player act at all), `agreement` (does
107
+ the label visibly move the world), `smooth` (lag-1 autocorrelation of frame difference — jittery
108
+ timing makes dynamics unlearnable), `motion`, `detail` (Laplacian variance), `clean` (1 − duplicate
109
+ rate), plus run length.
110
 
111
  ```python
112
+ import json
113
  from huggingface_hub import hf_hub_download
114
 
115
  REPO = "codelion/multi-drive-model-data"
116
+ best = [json.loads(l) for l in
117
+ open(hf_hub_download(REPO, "md_quality_top35.jsonl", repo_type="dataset")) if l.strip()]
118
+ print(len(best), "clips", sum(r["frames"] for r in best), "frames")
119
+ for r in best[:3]:
120
+ print(r["run"], r["tar"], round(r["score"], 3), "lag", r["best_lag"], "r", round(r["lag_r"], 2))
121
+ ```
122
 
123
+ | tier | clips | frames | share |
124
+ |---|---|---|---|
125
+ | `md_quality_top20.jsonl` | 30 | 356,198 | 33% |
126
+ | `md_quality_top35.jsonl` | 53 | 522,751 | 49% |
127
+ | `md_quality_top50.jsonl` | 76 | 680,408 | 63% |
128
+ | `md_quality_all.jsonl` | 153 | 1,073,285 | 100% |
129
 
130
+ Nothing is pruned from the tars — the ranking is shipped instead, so you can pick your own cutoff or
131
+ ignore ours.
 
 
 
 
132
 
133
+ ## Layout
134
 
135
+ The `.tar` files are **not a WebDataset**. Each holds one clip directory:
136
 
137
+ ```
138
+ <clip>/frames/frame_000000.jpg
139
+ <clip>/frames/frame_000001.jpg
140
+ ...
141
+ <clip>/actions.jsonl # one JSON line per frame, same order as the frames
142
+ <clip>/labelqc.json # relabelling QC for this clip
143
+ ```
144
+
145
+ A world model trains on contiguous windows, not independent samples, and WebDataset's flat
146
+ `key.jpg`/`key.json` pairing cannot express "these frames are consecutive and ordered" — the viewer
147
+ would shuffle them, which is meaningless for video. Tars also keep the repo to a few hundred objects
148
+ instead of a million, and keep neighbouring frames adjacent on disk. HF's auto-detection cannot parse
149
+ this layout, so the dataset viewer is off.
150
 
151
  ```python
152
+ import json, tarfile, glob, os
153
  import numpy as np
154
  from PIL import Image
155
+ from huggingface_hub import hf_hub_download
156
+
157
+ REPO = "codelion/multi-drive-model-data"
158
+ meta = [json.loads(l) for l in
159
+ open(hf_hub_download(REPO, "metadata.jsonl", repo_type="dataset")) if l.strip()]
160
+
161
+ tar = hf_hub_download(REPO, meta[0]["path"], repo_type="dataset")
162
+ with tarfile.open(tar) as tf:
163
+ tf.extractall("work")
164
 
165
  def load_run(run_dir):
166
  frames = sorted(glob.glob(os.path.join(run_dir, "frames", "*.jpg")))
167
  recs = [json.loads(l) for l in open(os.path.join(run_dir, "actions.jsonl")) if l.strip()]
168
+ n = min(len(frames), len(recs)) # always slice to the shorter of the two
169
+ return frames[:n], np.array([r["actions"] for r in recs[:n]], np.float32) # [n, 7]
 
170
 
171
  def windows(frames, actions, seq_len=16, stride=8):
 
172
  for s in range(0, len(frames) - seq_len + 1, stride):
173
+ imgs = np.stack([np.asarray(Image.open(f).convert("RGB"), np.float32) / 255.
174
+ for f in frames[s:s + seq_len]])
175
+ yield imgs, actions[s:s + seq_len] # [seq,H,W,3], [seq,7]
176
  ```
177
 
178
+ Horizontal-flip augmentation must mirror the controls too: swap indices 2↔3 and negate index 6.
179
 
180
+ ## What we found training on this
181
 
182
+ Reported because negative results are worth more than silence, and because they tell you where the
183
+ difficulty actually is.
184
+
185
+ We trained latent diffusion world models (ConvVAE codec + DiT, rectified flow, per-frame diffusion
186
+ forcing) on this data repeatedly. **Steering became genuinely controllable after the re-labelling**
187
+ — A/B at matched settings moved separation from +0.177 → −0.008 (old labels, i.e. backwards) to
188
+ +0.509 → +0.381 (new labels). That is what the alignment fix bought.
189
 
190
+ **Long-horizon stability was never solved.** Rollouts stay coherent for roughly 10–20 frames and then
191
+ degrade. That survived correct labels, quality selection, a purpose-trained codec, more capacity,
192
+ longer training, few-step distillation, and a different game domain entirely. We do not have an
193
+ explanation, and we are not claiming the data is the cause.
194
 
195
+ One measurement worth passing on: our codec retained **36%** of a frame's Laplacian edge energy where
196
+ Neural Drive's retained **58%** on identical frames, while scoring *higher* PSNR. PSNR flatters a
197
+ blurry autoencoder. If you train a codec on this data, do not use PSNR as the stopping signal.
198
 
199
+ ## Provenance and licence
200
 
201
+ Screen recordings of SuperTuxKart (open source), and of Forza Horizon, Need for Speed and Asphalt 9
202
+ (commercial titles), curated to gameplay only with a CLIP content classifier that removes menus,
203
+ car-select, results screens, loading and non-game content. Roughly 45% of the raw recordings were not
204
+ gameplay.
205
 
206
+ Footage of the commercial titles is included for research use; rights in the underlying games remain
207
+ with their publishers. Check your own jurisdiction and intended use before redistributing or training
208
+ commercially.