File size: 5,454 Bytes
cef78b4
 
811d14d
 
 
 
 
 
 
 
cef78b4
811d14d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
---
license: apache-2.0
library_name: pytorch
tags:
  - robotics
  - world action model
  - imitation-learning
  - vision-language-action
  - robocasa
  - lda
---

# LDA Robocasa Model

This repository provides the LDA Robocasa checkpoint and the auxiliary files required for inference with the LDA codebase.

- GitHub: [https://github.com/jiangranlv/LDA-1B](https://github.com/jiangranlv/LDA-1B)
- Project Page: [https://pku-epic.github.io/LDA/](https://pku-epic.github.io/LDA/)

## Files

The Hugging Face model repository contains:

```text
LDA-robocasa.pt
config.yaml
dataset_statistics.json
```

- `LDA-robocasa.pt`: PyTorch checkpoint weights.
- `config.yaml`: model configuration used to rebuild the LDA framework.
- `dataset_statistics.json`: dataset normalization statistics used to un-normalize predicted actions during inference.

## Required Local Directory Layout

The current LDA loader expects the `.pt` checkpoint to be placed inside a subdirectory, usually named `checkpoints`, while `config.yaml` and `dataset_statistics.json` must stay in the parent run directory.

After downloading the files, organize them locally as:

```text
LDA-robocasa/
|-- config.yaml
|-- dataset_statistics.json
`-- checkpoints/
    `-- LDA-robocasa.pt
```

The checkpoint path passed to LDA should be:

```text
LDA-robocasa/checkpoints/LDA-robocasa.pt
```

## Why This Layout Is Needed

`baseframework.from_pretrained()` loads the checkpoint path and infers the run directory from it:

```python
checkpoint_pt = Path(pretrained_checkpoint)
run_dir = checkpoint_pt.parents[1]
```

For example, if the checkpoint path is:

```text
LDA-robocasa/checkpoints/LDA-robocasa.pt
```

then the inferred run directory is:

```text
LDA-robocasa
```

The loader then expects to find:

```text
LDA-robocasa/config.yaml
LDA-robocasa/dataset_statistics.json
```

If `LDA-robocasa.pt` is placed directly next to `config.yaml` and `dataset_statistics.json`, the loader will infer the wrong parent directory and fail to find the required files.

## Download And Prepare

You can download the model repository with `huggingface_hub`:

```python
from pathlib import Path
import shutil

from huggingface_hub import snapshot_download

repo_dir = Path(snapshot_download(repo_id="YOUR_ORG_OR_USERNAME/LDA-robocasa"))

ckpt_dir = repo_dir / "checkpoints"
ckpt_dir.mkdir(exist_ok=True)

src_ckpt = repo_dir / "LDA-robocasa.pt"
dst_ckpt = ckpt_dir / "LDA-robocasa.pt"

if src_ckpt.exists() and not dst_ckpt.exists():
    shutil.move(str(src_ckpt), str(dst_ckpt))

print("Checkpoint path:", dst_ckpt)
```

Replace `YOUR_ORG_OR_USERNAME/LDA-robocasa` with the actual Hugging Face repository ID.

## Load The Model

```python
from lda.model.framework.base_framework import baseframework

ckpt_path = "LDA-robocasa/checkpoints/LDA-robocasa.pt"

model = baseframework.from_pretrained(ckpt_path)
model = model.to("cuda").eval()
```

## Start The Policy Server

From the LDA repository root, run:

```bash
python deployment/model_server/server_policy.py \
  --ckpt_path LDA-robocasa/checkpoints/LDA-robocasa.pt \
  --port 10093 \
  --use_bf16
```

## Run RoboCasa Evaluation

In a separate terminal with the RoboCasa environment activated, run:

```bash
export PYTHONPATH=$(pwd):${PYTHONPATH}

python examples/Robocasa_tabletop/eval_files/simulation_env.py \
  --args.env_name ${env_name} \
  --args.port 10093 \
  --args.n_episodes 50 \
  --args.n_envs 1 \
  --args.max_episode_steps 720 \
  --args.n_action_steps 12 \
  --args.video_out_path ${video_out_path} \
  --args.pretrained_path LDA-robocasa/checkpoints/LDA-robocasa.pt
```

You can also use the batch evaluation script:

```bash
bash examples/Robocasa_tabletop/eval_files/batch_eval_args.sh
```

Make sure the checkpoint path used by the script points to:

```text
LDA-robocasa/checkpoints/LDA-robocasa.pt
```

## Required Files Checklist

Before running inference, confirm that the following files exist:

```text
LDA-robocasa/config.yaml
LDA-robocasa/dataset_statistics.json
LDA-robocasa/checkpoints/LDA-robocasa.pt
```

The checkpoint file must:

- exist locally
- use the `.pt` suffix
- be placed one directory below the run directory

The config and statistics files must:

- be named exactly `config.yaml` and `dataset_statistics.json`
- be located in the inferred run directory
- correspond to the same training run as the checkpoint

## Troubleshooting

### Missing `config.yaml`

If you see an error similar to:

```text
Missing `config.yaml`
```

check that your local directory is organized as:

```text
LDA-robocasa/
|-- config.yaml
|-- dataset_statistics.json
`-- checkpoints/
    `-- LDA-robocasa.pt
```

and that you pass:

```text
LDA-robocasa/checkpoints/LDA-robocasa.pt
```

instead of:

```text
LDA-robocasa/LDA-robocasa.pt
```

### Missing `dataset_statistics.json`

If you see an error similar to:

```text
Missing `dataset_statistics.json`
```

make sure `dataset_statistics.json` is in the same directory as `config.yaml`, not inside the `checkpoints` directory.

### Invalid Checkpoint Suffix

The loader asserts that the checkpoint suffix is `.pt`. Make sure the checkpoint file is named:

```text
LDA-robocasa.pt
```

## Notes

`dataset_statistics.json` is required for action un-normalization. Removing or replacing it can cause predicted actions to be scaled incorrectly.

`config.yaml` is required because the LDA framework is rebuilt from the saved configuration before loading the checkpoint weights.