File size: 5,734 Bytes
e4da1db
 
 
2019c94
 
 
 
5506fc9
07c527e
 
e4da1db
 
 
 
 
 
16fc17c
e4da1db
 
 
 
6b2594b
 
 
e4da1db
 
 
0679fff
 
 
e4da1db
 
3790790
 
e4da1db
 
 
 
 
 
 
622d9c9
e4da1db
 
 
 
 
a148ac7
 
 
e4da1db
913e058
622d9c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0153f2c
 
7e5523d
622d9c9
7e5523d
622d9c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
913e058
 
622d9c9
 
 
 
 
 
 
 
 
 
 
 
913e058
 
 
 
 
 
 
 
ec0ae7c
913e058
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e7987a2
913e058
 
 
 
7ccb334
622d9c9
 
 
 
 
 
 
 
 
 
 
 
 
913e058
622d9c9
 
913e058
 
 
 
 
 
 
 
 
 
 
e8107d7
913e058
622d9c9
e4da1db
 
0679fff
622d9c9
 
913e058
e4da1db
 
 
 
 
 
 
a148ac7
c1cc91b
 
 
 
dd1d159
e4da1db
 
 
 
8cf039f
4bc8143
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198

<br>
<p align="center">

<p align="center">
  <img src="assets/worldmem_logo.png" alt="WORLDMEM Icon" width="80"/>
</p>
<h1 align="center"><strong>WorldMem: Long-term Consistent World Simulation <br> with Memory</strong></h1>
  <p align="center"><span><a href=""></a></span>
              <a href="https://xizaoqu.github.io">Zeqi Xiao<sup>1</sup></a>
              <a href="https://nirvanalan.github.io/">Yushi Lan<sup>1</sup></a>
              <a href="https://zhouyifan.net/about/">Yifan Zhou<sup>1</sup></a>
              <a href="https://vicky0522.github.io/Wenqi-Ouyang/">Wenqi Ouyang<sup>1</sup></a>
              <a href="https://williamyang1991.github.io/">Shuai Yang<sup>2</sup></a>
              <a href="https://zengyh1900.github.io/">Yanhong Zeng<sup>3</sup></a>
              <a href="https://xingangpan.github.io/">Xingang Pan<sup>1</sup></a>    <br>
    <sup>1</sup>S-Lab, Nanyang Technological University, <br> <sup>2</sup>Wangxuan Institute of Computer Technology, Peking University,<br>  <sup>3</sup>Shanghai AI Laboratory
    </p>
</p>

<p align="center">
  <a href="https://arxiv.org/abs/2504.12369" target='_blank'>
    <img src="https://img.shields.io/badge/arXiv-2504.12369-blue?">
  </a>
  <a href="https://xizaoqu.github.io/worldmem/" target='_blank'>
    <img src="https://img.shields.io/badge/Project-&#x1F680-blue">
  </a>
<a href="https://huggingface.co/spaces/yslan/worldmem" target="_blank">
  <img src="https://img.shields.io/badge/πŸ€— HuggingFace-Demo-orange" />
</a>
</p>

https://github.com/user-attachments/assets/fb8a32e2-9470-4819-a93d-c38caf76d72c


## Installation

```
conda create python=3.10 -n worldmem
conda activate worldmem
pip install -r requirements.txt
conda install -c conda-forge ffmpeg=4.3.2
```


## Quick start

```
python app.py
```

## Run

To enable cloud logging with [Weights & Biases (wandb)](https://wandb.ai/site), follow these steps:

1. Sign up for a wandb account.
2. Run the following command to log in:

    ```bash
    wandb login
    ```

3. Open `configurations/training.yaml` and set the `entity` and `project` field to your wandb username.

---

### Training

Download pretrained weights from [Oasis](https://github.com/etched-ai/open-oasis).

Training the model on 4 H100 GPUs, it converges after approximately 500K steps.
We observe that gradually increasing task difficulty improves performance. Thus, we adopt a multi-stage training strategy:
, 
```bash
sh train_stage_1.sh   # Small range, no vertical turning
sh train_stage_2.sh   # Large range, no vertical turning
sh train_stage_3.sh   # Large range, with vertical turning
```

To resume training from a previous checkpoint, configure the `resume` and `output_dir` variables in the corresponding `.sh` script.

---

### Inference

To run inference:

```bash
sh infer.sh
```

You can either **load the diffusion model and VAE separately**:

```bash
+diffusion_model_path=zeqixiao/worldmem_checkpoints/diffusion_only.ckpt \
+vae_path=zeqixiao/worldmem_checkpoints/vae_only.ckpt \
+customized_load=true \
+seperate_load=true \
```

Or **load a combined checkpoint**:

```bash
+load=your_model_path \
+customized_load=true \
+seperate_load=false \
```

### Evaluation

To run evaluation:

```bash
sh evaluate.sh
```

This script reproduces the results in Table 1 (beyond context window). It will generate PSNR and Lpips. Evaluating 1 case on 1 A100 GPU takes approximately 6 minutes. You can adjust `experiment.test.limit_batch` to specify the number of cases to evaluate. 

Visual results will be saved by default to a timestamped directory (e.g., `outputs/2025-11-30/00-02-42`).

To calculate the FID score, run:

```bash
python calculate_fid.py --videos_dir <path_to_videos>
```

For example:

```bash
python calculate_fid.py --videos_dir outputs/2025-11-30/00-02-42/videos/test_vis
```

**Expected Results:**

| Metric | Value  |
|--------|--------|
| PSNR   | 24.01  |
| LPIPS  | 0.1667 |
| FID    | 15.13  |

*Note: FID is computed over 5000 frames.*

---

## Dataset

Download the Minecraft dataset from [Hugging Face](https://huggingface.co/datasets/zeqixiao/worldmem_minecraft_dataset)

Place the dataset in the following directory structure:

```
data/
└── minecraft/
    β”œβ”€β”€ training/
    └── validation/
    └── test/
```

## Data Generation

After setting up the environment as described in [MineDojo's GitHub repository](https://github.com/MineDojo/MineDojo), you can generate data using the following command:

```bash
xvfb-run -a python data_generator.py -o data/test -z 4 --env_type plains
```

**Parameters:**
- `-o`: Output directory for generated data
- `-z`: Number of parallel workers
- `--env_type`: Environment type (e.g., `plains`)


## TODO

- [x] Release inference models and weights;
- [x] Release training pipeline on Minecraft;
- [x] Release training data on Minecraft;
- [x] Release evaluation scripts and data generator.



## πŸ”— Citation

If you find our work helpful, please cite:

```
@inproceedings{xiaoworldmem,
  title={WorldMem: Long-term Consistent World Simulation with Memory},
  author={Xiao, Zeqi and Yushi, LAN and Zhou, Yifan and Ouyang, Wenqi and Yang, Shuai and Zeng, Yanhong and Pan, Xingang},
  booktitle={The Thirty-ninth Annual Conference on Neural Information Processing Systems}
}
```

## πŸ‘ Acknowledgements
- [Diffusion Forcing](https://github.com/buoyancy99/diffusion-forcing): Diffusion Forcing provides flexible training and inference strategies for our methods.
- [Minedojo](https://github.com/MineDojo/MineDojo): We collect our Minecraft dataset from Minedojo.
- [Open-oasis](https://github.com/etched-ai/open-oasis): Our model architecture is based on Open-oasis. We also use pretrained VAE and DiT weight from it.