File size: 5,169 Bytes
319eb16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# LIBERO Dataset Guide

LIBERO is a benchmark for lifelong robot learning with built-in support in the Robometer training pipeline.

## Overview

- **๐Ÿ“ Local File Support**: Processes HDF5 files from local storage
- **๐ŸŽฎ Simulation Data**: High-quality manipulation tasks
- **๐Ÿ  Multiple Environments**: Living room, kitchen, office, and study scenarios
- **๐Ÿ“Š Structured Tasks**: Clear task descriptions and optimal trajectories

## Prerequisites

### Download LIBERO Dataset
```bash
# Clone or download LIBERO dataset
git clone https://github.com/Lifelong-Robot-Learning/LIBERO.git
# Follow LIBERO installation instructions for dataset download

# This should work too
git submodule update --init --recursive

cd deps/libero/LIBERO
uv run python benchmark_scripts/download_libero_datasets.py --datasets DATASET
```
where DATASET is chosen from `[libero_spatial, libero_object, libero_100, libero_goal]`.


## Quick Start

### 0. Set Hugging Face repo ID
Before we start, you must have an HF account which will be pushed to.
You will set this by setting
```
export HF_USERNAME=<insert HF username here>
```

Then, for each dataset, run with the all the datasets you would like to process

### Option 1: Use Default Configuration
```bash
uv run python dataset_upload/generate_hf_dataset.py \
    --config_path=dataset_upload/configs/data_gen_configs/libero.yaml\
    --dataset.dataset_path=deps/libero/LIBERO/libero/datasets/libero_90 \
    --dataset.dataset_name=libero_90
```

If all your LIBERO data exists in the path above, you can use the following utility script
```bash
uv run bash dataset_upload/data_scripts/libero/gen_all_libero.sh
```

### Option 2: Custom Configuration
```bash
uv run python dataset_upload/generate_hf_dataset.py \
    --config_path=dataset_upload/configs/data_gen_configs/libero.yaml \
    --dataset.dataset_path=/path/to/your/libero/dataset \
    --dataset.dataset_name=libero_custom \
    --output.output_dir=libero_robometer_dataset \
    --output.max_trajectories=1000 \
    --output.use_video=true \
    --output.fps=10
```

## Configuration Options

Create a custom config file `configs/data_gen_configs/libero.yaml`:

```yaml
dataset:
  dataset_path: LIBERO/libero/datasets/libero_90
  dataset_name: libero_90

output:
  output_dir: libero_dataset
  max_trajectories: -1  # Process all trajectories
  max_frames: 32
  use_video: true
  fps: 10

hub:
  push_to_hub: false
  hub_repo_id: your-username/libero_rfm
```

## Data Structure Processed

```
LIBERO Dataset:
โ”œโ”€โ”€ *.hdf5 files             โ† PROCESSED
โ”‚   โ”œโ”€โ”€ /data/
โ”‚   โ”‚   โ””โ”€โ”€ trajectory_*/
โ”‚   โ”‚       โ”œโ”€โ”€ obs/
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ agentview_rgb    โ† EXTRACTED as frames
โ”‚   โ”‚       โ””โ”€โ”€ actions              โ† EXTRACTED as actions
โ””โ”€โ”€ Generated Output:
    โ”œโ”€โ”€ frames: List[np.ndarray]     โ† RGB video frames
    โ”œโ”€โ”€ actions: np.ndarray          โ† Robot actions
    โ”œโ”€โ”€ task: str                    โ† Parsed from filename
    โ””โ”€โ”€ optimal: "optimal"           โ† All LIBERO data assumed optimal
```

## Supported LIBERO Variants

- **LIBERO-90**: 90 tasks across 4 environments
- **LIBERO-10**: 10 benchmark tasks
- **Custom datasets**: Any LIBERO-format HDF5 files

## Sample Output

```
Loading LIBERO dataset from: LIBERO/libero/datasets/libero_90
Found 90 HDF5 files
Processing LIBERO dataset, 90 files: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 90/90

Sample trajectory:
- Task: "stack the right bowl on the left bowl and place them in the tray"
- Frames: (128, 128, 128, 3) RGB images
- Actions: (128, 7) joint positions
- Environment: LIVING_ROOM_SCENE4
```

## File Name Parsing

LIBERO dataset automatically parses task information from HDF5 filenames:

```
LIVING_ROOM_SCENE4_stack_the_right_bowl_on_the_left_bowl_and_place_them_in_the_tray.hdf5
โ”‚              โ”‚    โ”‚
โ”‚              โ”‚    โ””โ”€โ”€ Task description
โ”‚              โ””โ”€โ”€ Scene identifier  
โ””โ”€โ”€ Environment type
```

## Performance Notes

- **Processing Speed**: ~2-5 files/second
- **Memory Usage**: Moderate (loads one HDF5 file at a time)
- **Storage**: Variable (depends on trajectory length)
- **Video Encoding**: Converts RGB arrays to MP4 format

## Troubleshooting

### HDF5 File Issues
```python
# Check HDF5 file structure
import h5py
with h5py.File('path/to/file.hdf5', 'r') as f:
    print(list(f.keys()))  # Should show 'data'
    print(list(f['data'].keys()))  # Should show trajectory keys
```

### Missing Observations
Ensure your LIBERO dataset has the expected structure:
```
/data/demo_0/obs/agentview_rgb  # RGB frames
/data/demo_0/actions            # Action sequences
```

### Memory Issues
For large LIBERO datasets:
```bash
# Process in chunks
uv run python data/generate_hf_dataset.py \
    --config_path=configs/data_gen_configs/libero.yaml \
    --output.max_trajectories=100  # Limit trajectories
```

## Integration with Robometer Training

```bash
# Train on processed LIBERO dataset
uv run accelerate launch --config_file configs/fsdp.yaml train.py \
    --config_path=configs/config.yaml \
    --dataset.dataset_path=libero_dataset/libero_90
```