CONTROL Resonant IDM
An inverse dynamics model for the game CONTROL Resonant. It watches gameplay video and predicts what the gamepad was doing on every frame: the 21 buttons and both analog sticks. The purpose is to label gameplay footage that has no recorded input, so it can be used to train a playing agent.
This is a single-game model. Models for other games live next to it in the games_idm collection and are kept separate for now.
Results
Scored against the real gamepad input recorded alongside the video, on the validation block: the stretch from 30% to 40% of every session, which is never used for training.
All 27 sessions (about 100 minutes of validation video):
| model | stick error | stick error, sticks at rest | button F1 | button AP |
|---|---|---|---|---|
| this version (27 sessions) | 0.080 | 0.131 | 0.34 | 0.35 |
| previous version (8 sessions) | 0.089 | 0.131 | 0.26 | 0.26 |
The first 8 sessions only, where both versions held out the same block:
| model | stick error | stick error, sticks at rest | button F1 | button AP |
|---|---|---|---|---|
| this version (27 sessions) | 0.108 | 0.183 | 0.34 | 0.33 |
| previous version (8 sessions) | 0.115 | 0.183 | 0.27 | 0.27 |
Stick error is the mean absolute error over the four stick axes, each in [-1, 1]. "Sticks at
rest" is the error of always predicting centred sticks, which is the baseline to beat. Button F1
(at a probability threshold of 0.5) and AP are averaged over the buttons that were pressed at
least once in the block. In the first table the previous version is at a disadvantage: it never
saw any part of sessions s09 to s27, while this version trained on the rest of them. The
second table is the like-for-like comparison.
Unlike the previous version, this one has no sessions that were held out completely: every recorded session contributes to training, and only the validation block of each is unseen.
Per-button scores of this version on the 27-session block:
| button | F1 | AP |
|---|---|---|
| Left trigger | 0.67 | 0.68 |
| Left bumper | 0.60 | 0.80 |
| X (west) | 0.58 | 0.52 |
| A (south) | 0.58 | 0.67 |
| B (east) | 0.52 | 0.53 |
| Y (north) | 0.51 | 0.58 |
| D-pad down | 0.44 | 0.43 |
| Right bumper | 0.29 | 0.26 |
| Right trigger | 0.29 | 0.22 |
| Left stick click | 0.29 | 0.22 |
| D-pad up | 0.13 | 0.07 |
| D-pad right | 0.11 | 0.13 |
| D-pad left | 0.10 | 0.09 |
| Start | 0.00 | 0.01 |
| Right stick click | 0.00 | 0.00 |
What this means in practice:
- Stick labels are useful: the error is 39% below the at-rest baseline.
- The main action buttons are right about half of the time or better.
- The rarest buttons (most of the D-pad, right stick click, Start) are not learned yet. They are almost absent from the training data.
- A press that changes nothing on screen cannot be recovered from video by any model.
Usage
pip install torch transformers safetensors numpy
# ffmpeg must be on PATH
from huggingface_hub import snapshot_download
import sys
folder = snapshot_download("XvKuoMing/control-resonant-idm")
sys.path.insert(0, folder)
from idm import load, label_video, BUTTONS
model = load(folder) # cuda by default, load(folder, "cpu") also works
out = label_video(model, "gameplay.mp4")
out["buttons"] # (frames, 21) uint8, column order = BUTTONS
out["probs"] # (frames, 21) float32, probability of each button being held
out["sticks"] # (frames, 4) float32: left x, left y, right x, right y
Frame k of the output is video time k / 60 seconds. Sticks are in [-1, 1] with x to the right
and y down. label_video decodes the whole file into memory (about 12 GB per hour of video), so
split long recordings into pieces of a few minutes, or decode in chunks and call label_frames.
From the command line, python idm.py gameplay.mp4 writes gameplay.actions.npz.
Input
- Video resampled to 60 fps.
- The full 16:9 frame squashed to 256×256 (no crop), RGB.
- The model was trained on 1080p captures with the in-game HUD visible. Other resolutions work as long as the whole frame is passed in.
Architecture
| part | detail |
|---|---|
| frame encoder | SigLIP 2 large, patch 16, 256 px (fine-tuned) |
| tokens per frame | 16×16 patches projected to 512 dimensions, average-pooled to 4×4 |
| temporal model | 4-layer transformer, 8 heads, over all tokens of the window |
| window | 8 frames, every 2nd frame at 60 fps (267 ms) |
| outputs per frame | 21 button logits, 4 stick values through tanh |
| parameters | 329 M |
Button order: BACK, DPAD_DOWN, DPAD_LEFT, DPAD_RIGHT, DPAD_UP, EAST, GUIDE, LEFT_SHOULDER, LEFT_THUMB, LEFT_TRIGGER, NORTH, RIGHT_BOTTOM, RIGHT_LEFT, RIGHT_RIGHT, RIGHT_SHOULDER, RIGHT_THUMB, RIGHT_TRIGGER, RIGHT_UP, SOUTH, START, WEST. EAST/SOUTH/WEST/NORTH are B/A/X/Y on an
Xbox pad. The triggers are treated as buttons (held or not).
Training
- Data: 27 recording sessions of one player, 16.6 hours, with gamepad input logged at 1000 Hz and
aligned to the video.
The recordings are published as the
control-resonant dataset,
sessions
s01tos27. The published clips are shorter (14.7 hours) because stretches outside the game are cut from them. - Validation: a contiguous block of each session (from 30% to 40% of its length), never used for training.
- 20000 steps, batch 16, AdamW, learning rate 1e-4 (1e-5 for the frame encoder), weight decay 0.01.
- Loss: binary cross-entropy on buttons, with positives of rare buttons weighted up to 10×, plus L1 on sticks.
- Frames with no input at all were thinned to 30% so that idle time does not dominate.
- This checkpoint is the one with the lowest validation loss (the final step). Validation scores had mostly levelled off over the last 4000 steps.
Limitations
- One game, one player, one controller layout, one graphics setup.
- Trained on 16.6 hours. Expect it to fail on scenes it has rarely seen, such as menus and cutscenes.
- Button labels are too noisy to be used as ground truth without filtering by probability.