Upload folder using huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: pytorch
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
model_name: space-invaders-world-model
|
| 5 |
+
tags:
|
| 6 |
+
- world-model
|
| 7 |
+
- diffusion
|
| 8 |
+
- atari
|
| 9 |
+
- space-invaders
|
| 10 |
+
- video-generation
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# space-invaders-world-model
|
| 14 |
+
|
| 15 |
+
A diffusion world model of Atari Space Invaders, trained from scratch. Given the last 4 frames and actions, a small U-Net denoises the next 64×64 frame; fed its own frames, it generates a video that your actions steer. After [DIAMOND](https://arxiv.org/abs/2405.12399). `atari.py` in this repo collects the data, trains, plays and doubles as the loader.
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
## 🚀 Usage
|
| 20 |
+
|
| 21 |
+
Play it in the browser. Each button press generates one frame:
|
| 22 |
+
|
| 23 |
+
```
|
| 24 |
+
uv run "$(hf download jgalego/space-invaders-world-model atari.py --quiet)" play --game SpaceInvaders
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
From Python, with `atari.py` on the path:
|
| 28 |
+
|
| 29 |
+
```python
|
| 30 |
+
import torch
|
| 31 |
+
from atari import DEVICE, collect, load, rollout, to_float
|
| 32 |
+
|
| 33 |
+
model = load("jgalego/space-invaders-world-model")
|
| 34 |
+
frames, _, _ = collect(4, seed=0, game="SpaceInvaders") # four real frames to start from
|
| 35 |
+
context = to_float(frames[:4])[None].to(DEVICE)
|
| 36 |
+
moves = torch.tensor([[0, 0, 0] + [1] * 16], device=DEVICE) # FIRE for 16 frames
|
| 37 |
+
video = rollout(model, context, moves) # (1, 16, 3, 64, 64) in [-1, 1]
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
Actions: 0 NOOP, 1 FIRE, 2 RIGHT, 3 LEFT, 4 RIGHTFIRE, 5 LEFTFIRE.
|
| 41 |
+
|
| 42 |
+
## 🏋️ Training
|
| 43 |
+
|
| 44 |
+
Not trained yet.
|
| 45 |
+
|
| 46 |
+
## 📊 Results
|
| 47 |
+
|
| 48 |
+
Rollouts on held-out windows from episodes whose seeds never appear in training. The model gets four real frames and the real actions, then only its own frames. **Repeat** keeps showing the last real frame. Much of an Atari frame never changes, so **changed pixels** scores only the pixels where the real or the predicted frame differs from the last real frame.
|
| 49 |
+
|
| 50 |
+
Not evaluated yet.
|
| 51 |
+
|
| 52 |
+
## ⚠️ Limitations
|
| 53 |
+
|
| 54 |
+
- A random policy does not get far, so the model knows the early game best.
|
| 55 |
+
- 64×64 frames: small sprites are a pixel or two and can blur or vanish over long rollouts.
|
| 56 |
+
- Errors compound: every generated frame becomes input for the next.
|