Datasets:
Update README with LanceDB examples
Browse files
README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
license: apache-2.0
|
| 3 |
task_categories:
|
| 4 |
- robotics
|
|
|
|
| 5 |
language:
|
| 6 |
- en
|
| 7 |
tags:
|
|
@@ -17,37 +18,92 @@ size_categories:
|
|
| 17 |
---
|
| 18 |
# LeRobot PushT (Lance Format)
|
| 19 |
|
| 20 |
-
Lance-formatted version of [`lerobot/pusht`](https://huggingface.co/datasets/lerobot/pusht) — the canonical PushT benchmark from the [Diffusion Policy paper](https://diffusion-policy.cs.columbia.edu/) — packaged using the same three-table layout as
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
## Tables
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|---|---|
|
| 28 |
-
| `frames.lance` | One row per frame — observations, actions, episode index, task index. |
|
| 29 |
-
| `videos.lance` | One row per source MP4 — full per-camera video stored as an inline blob. |
|
| 30 |
-
| `episodes.lance` | One row per episode — full timestamps + actions + per-camera video segment blobs. |
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
-
##
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
```
|
| 47 |
|
| 48 |
## Load with LanceDB
|
| 49 |
|
| 50 |
-
|
| 51 |
|
| 52 |
```python
|
| 53 |
import lancedb
|
|
@@ -55,55 +111,208 @@ import lancedb
|
|
| 55 |
db = lancedb.connect("hf://datasets/lance-format/lerobot-pusht-lance/data")
|
| 56 |
|
| 57 |
frames = db.open_table("frames")
|
| 58 |
-
videos = db.open_table("videos")
|
| 59 |
episodes = db.open_table("episodes")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
|
| 62 |
-
print(
|
| 63 |
-
print(
|
| 64 |
```
|
| 65 |
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
```python
|
| 69 |
import lancedb
|
| 70 |
|
| 71 |
db = lancedb.connect("hf://datasets/lance-format/lerobot-pusht-lance/data")
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
.
|
| 78 |
-
.
|
| 79 |
-
.limit(5)
|
| 80 |
.to_list()
|
| 81 |
)
|
| 82 |
-
for
|
| 83 |
-
print(
|
| 84 |
```
|
| 85 |
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
```python
|
| 89 |
-
|
| 90 |
-
import lance
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
-
#
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
```
|
| 101 |
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
-
|
| 105 |
-
- Inline video blobs use Lance's blob encoding so metadata scans never load the bytes; you fetch them on demand via `take_blobs`.
|
| 106 |
-
- Schema evolution: add columns (alternate camera streams, language annotations, model predictions) without rewriting the data.
|
| 107 |
|
| 108 |
## Source & license
|
| 109 |
|
|
|
|
| 2 |
license: apache-2.0
|
| 3 |
task_categories:
|
| 4 |
- robotics
|
| 5 |
+
- lance
|
| 6 |
language:
|
| 7 |
- en
|
| 8 |
tags:
|
|
|
|
| 18 |
---
|
| 19 |
# LeRobot PushT (Lance Format)
|
| 20 |
|
| 21 |
+
A Lance-formatted version of [`lerobot/pusht`](https://huggingface.co/datasets/lerobot/pusht) — the canonical PushT benchmark from the [Diffusion Policy paper](https://diffusion-policy.cs.columbia.edu/) — packaged using the same three-table layout as [`lance-format/lerobot-xvla-soft-fold`](https://huggingface.co/datasets/lance-format/lerobot-xvla-soft-fold) so consumers can flip between datasets without changing code. Available directly from the Hub at `hf://datasets/lance-format/lerobot-pusht-lance/data`.
|
| 22 |
+
|
| 23 |
+
## Key features
|
| 24 |
+
|
| 25 |
+
- **Three-table layout** — `frames`, `episodes`, `videos` — so frame-level training, episode-level trajectory work, and raw video access live side-by-side without scattered parquet shards or sidecar MP4 directories.
|
| 26 |
+
- **Inline MP4 segments** in `episodes.lance` (one blob per camera, with `from_timestamp` / `to_timestamp` bounds) and full source MP4s in `videos.lance`, all surfaced as lazy `BlobFile` handles via `take_blobs` so metadata scans never read the bytes.
|
| 27 |
+
- **Frame-level observations and actions** in `frames.lance` with stable `episode_index`, `frame_index`, and `index` columns for joining or temporal iteration.
|
| 28 |
+
- **Schema-evolution friendly** — add alternate camera streams, language annotations, or model predictions later without rewriting the data.
|
| 29 |
|
| 30 |
## Tables
|
| 31 |
|
| 32 |
+
| Table | Rows ~ | Purpose |
|
| 33 |
+
|---|---|---|
|
| 34 |
+
| `frames.lance` | one row per frame | Per-frame observations, actions, episode/task indices |
|
| 35 |
+
| `episodes.lance` | one row per episode | Full per-episode trajectories plus per-camera MP4 segment blobs and timestamp bounds |
|
| 36 |
+
| `videos.lance` | one row per source MP4 | Raw source video blobs and file-level provenance (path, size, sha256) |
|
| 37 |
|
| 38 |
+
Use `frames.lance` for low-level training (loss-per-timestep, state-conditioned policies). Use `episodes.lance` when you need the full trajectory and the matching video segments together. Use `videos.lance` when you want direct access to the original encoded video files.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
## Schemas
|
| 41 |
|
| 42 |
+
### `frames.lance`
|
| 43 |
|
| 44 |
+
| Column | Type | Notes |
|
| 45 |
+
|---|---|---|
|
| 46 |
+
| `observation_state` | `list<float32>` | Robot state vector for that frame |
|
| 47 |
+
| `action` | `list<float32>` | Action vector for that frame |
|
| 48 |
+
| `timestamp` | `float` | Canonical frame timestamp (seconds) |
|
| 49 |
+
| `frame_index` | `int64` | Frame index within episode |
|
| 50 |
+
| `episode_index` | `int64` | Parent episode id |
|
| 51 |
+
| `index` | `int64` | Global frame index |
|
| 52 |
+
| `task_index` | `int64` | Task id |
|
| 53 |
+
|
| 54 |
+
### `episodes.lance`
|
| 55 |
+
|
| 56 |
+
| Column | Type | Notes |
|
| 57 |
+
|---|---|---|
|
| 58 |
+
| `episode_index` | `int64` | Episode id |
|
| 59 |
+
| `task_index` | `int64` | Task id |
|
| 60 |
+
| `fps` | `int32` | Frame rate of the episode video segments |
|
| 61 |
+
| `timestamps` | `list<float32>` | Per-frame timestamps |
|
| 62 |
+
| `actions` | `list<list<float32>>` | Per-frame action vectors |
|
| 63 |
+
| `observation_state` | `list<list<float32>>` | Per-frame robot state vectors |
|
| 64 |
+
| `<camera>_video_blob` | `large_binary` (blob-encoded) | Inline MP4 segment for each camera, read lazily via `take_blobs` |
|
| 65 |
+
| `<camera>_from_timestamp` | `float64` | Segment start time |
|
| 66 |
+
| `<camera>_to_timestamp` | `float64` | Segment end time |
|
| 67 |
+
|
| 68 |
+
### `videos.lance`
|
| 69 |
+
|
| 70 |
+
| Column | Type | Notes |
|
| 71 |
+
|---|---|---|
|
| 72 |
+
| `camera_angle` | `string` | Camera key |
|
| 73 |
+
| `chunk_index`, `file_index` | `int32` | IDs parsed from the source path |
|
| 74 |
+
| `relative_path`, `filename` | `string` | Provenance |
|
| 75 |
+
| `file_size_bytes` | `int64` | Source MP4 size |
|
| 76 |
+
| `sha256` | `string` | SHA256 of the MP4 bytes |
|
| 77 |
+
| `video_blob` | `large_binary` (blob-encoded) | Raw source MP4 bytes |
|
| 78 |
+
|
| 79 |
+
## Pre-built indices
|
| 80 |
+
|
| 81 |
+
None bundled. Build indices on a local copy if a workload calls for them — e.g., a `BTREE` on `frames.episode_index` for fast episode lookup, or a vector index after attaching observation embeddings via Evolve.
|
| 82 |
+
|
| 83 |
+
## Why Lance?
|
| 84 |
|
| 85 |
+
1. **Blazing Fast Random Access**: Optimized for fetching scattered rows, making it ideal for random sampling, real-time ML serving, and interactive applications without performance degradation.
|
| 86 |
+
2. **Native Multimodal Support**: Store text, embeddings, and other data types together in a single file. Large binary objects are loaded lazily, and vectors are optimized for fast similarity search.
|
| 87 |
+
3. **Native Index Support**: Lance comes with fast, on-disk, scalable vector and FTS indexes that sit right alongside the dataset on the Hub, so you can share not only your data but also your embeddings and indexes without your users needing to recompute them.
|
| 88 |
+
4. **Efficient Data Evolution**: Add new columns and backfill data without rewriting the entire dataset. This is perfect for evolving ML features, adding new embeddings, or introducing moderation tags over time.
|
| 89 |
+
5. **Versatile Querying**: Supports combining vector similarity search, full-text search, and SQL-style filtering in a single query, accelerated by on-disk indexes.
|
| 90 |
+
6. **Data Versioning**: Every mutation commits a new version; previous versions remain intact on disk. Tags pin a snapshot by name, so retrieval systems and training runs can reproduce against an exact slice of history.
|
| 91 |
|
| 92 |
+
## Load with `datasets.load_dataset`
|
| 93 |
+
|
| 94 |
+
You can load Lance datasets via the standard HuggingFace `datasets` interface, suitable when your pipeline already speaks `Dataset` / `IterableDataset` or you want a quick streaming sample. Each Lance table is a separate `datasets` config.
|
| 95 |
+
|
| 96 |
+
```python
|
| 97 |
+
import datasets
|
| 98 |
+
|
| 99 |
+
hf_ds = datasets.load_dataset("lance-format/lerobot-pusht-lance", split="frames", streaming=True)
|
| 100 |
+
for row in hf_ds.take(3):
|
| 101 |
+
print(row["episode_index"], row["frame_index"], row["action"])
|
| 102 |
```
|
| 103 |
|
| 104 |
## Load with LanceDB
|
| 105 |
|
| 106 |
+
LanceDB is the embedded retrieval library built on top of the Lance format ([docs](https://lancedb.com/docs)), and is the interface most users interact with. Each `.lance` file in `data/` is a table — open by name. The same handles are used by the Search, Curate, Evolve, Train, Versioning, and Materialize-a-subset sections below.
|
| 107 |
|
| 108 |
```python
|
| 109 |
import lancedb
|
|
|
|
| 111 |
db = lancedb.connect("hf://datasets/lance-format/lerobot-pusht-lance/data")
|
| 112 |
|
| 113 |
frames = db.open_table("frames")
|
|
|
|
| 114 |
episodes = db.open_table("episodes")
|
| 115 |
+
videos = db.open_table("videos")
|
| 116 |
+
print(len(frames), len(episodes), len(videos))
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
## Load with Lance
|
| 120 |
+
|
| 121 |
+
`pylance` is the Python binding for the Lance format and works directly with the format's lower-level APIs. Reach for it when you want to inspect dataset internals — schema, scanner, fragments, the list of pre-built indices — or when you need the blob-level `take_blobs` entry point that streams MP4 bytes lazily from inline storage.
|
| 122 |
+
|
| 123 |
+
```python
|
| 124 |
+
import lance
|
| 125 |
|
| 126 |
+
ds = lance.dataset("hf://datasets/lance-format/lerobot-pusht-lance/data/frames.lance")
|
| 127 |
+
print(ds.count_rows(), ds.schema.names)
|
| 128 |
+
print(ds.list_indices())
|
| 129 |
```
|
| 130 |
|
| 131 |
+
> **Tip — for production use, download locally first.** Streaming from the Hub works for exploration, but heavy random access to video segments and any kind of indexed search are dramatically faster against a local copy:
|
| 132 |
+
> ```bash
|
| 133 |
+
> hf download lance-format/lerobot-pusht-lance --repo-type dataset --local-dir ./lerobot-pusht
|
| 134 |
+
> ```
|
| 135 |
+
> Then point Lance or LanceDB at `./lerobot-pusht/data`.
|
| 136 |
+
|
| 137 |
+
## Search
|
| 138 |
+
|
| 139 |
+
PushT does not ship a vector index out of the box — observation states are low-dimensional and most robotics workflows look up by index rather than by similarity. The bundled identifier columns (`episode_index`, `task_index`, `frame_index`) make exact lookups a single filtered scan. The example below pulls the first few frames of episode 0 from the frames table.
|
| 140 |
|
| 141 |
```python
|
| 142 |
import lancedb
|
| 143 |
|
| 144 |
db = lancedb.connect("hf://datasets/lance-format/lerobot-pusht-lance/data")
|
| 145 |
+
frames = db.open_table("frames")
|
| 146 |
+
|
| 147 |
+
slice_ = (
|
| 148 |
+
frames.search()
|
| 149 |
+
.where("episode_index = 0 AND frame_index < 10", prefilter=True)
|
| 150 |
+
.select(["episode_index", "frame_index", "timestamp", "action", "observation_state"])
|
| 151 |
+
.limit(10)
|
|
|
|
| 152 |
.to_list()
|
| 153 |
)
|
| 154 |
+
for r in slice_:
|
| 155 |
+
print(r["frame_index"], r["timestamp"], r["action"])
|
| 156 |
```
|
| 157 |
|
| 158 |
+
For similarity-style search across states or actions, attach an embedding column via Evolve and build an `IVF_PQ` index on it (see Evolve below). For visual similarity over rendered frames, the pre-extracted-frames pattern in Train below produces a table that can carry a learned image embedding alongside the pixels.
|
| 159 |
+
|
| 160 |
+
## Curate
|
| 161 |
+
|
| 162 |
+
A typical curation pass for a robotics workflow starts with an episode-level filter — pick episodes with a particular task, length, or initial condition — and then drops down to the frames within those episodes. Stacking predicates inside a single filtered scan keeps the result small and explicit, and the bounded `.limit(...)` makes it cheap to inspect.
|
| 163 |
|
| 164 |
```python
|
| 165 |
+
import lancedb
|
|
|
|
| 166 |
|
| 167 |
+
db = lancedb.connect("hf://datasets/lance-format/lerobot-pusht-lance/data")
|
| 168 |
+
episodes = db.open_table("episodes")
|
| 169 |
+
frames = db.open_table("frames")
|
| 170 |
+
|
| 171 |
+
# Pick a handful of episodes for the default task.
|
| 172 |
+
ep_rows = (
|
| 173 |
+
episodes.search()
|
| 174 |
+
.where("task_index = 0", prefilter=True)
|
| 175 |
+
.select(["episode_index", "fps", "observation_images_image_from_timestamp",
|
| 176 |
+
"observation_images_image_to_timestamp"])
|
| 177 |
+
.limit(10)
|
| 178 |
+
.with_row_id(True)
|
| 179 |
+
.to_list()
|
| 180 |
+
)
|
| 181 |
+
ep_ids = [r["episode_index"] for r in ep_rows]
|
| 182 |
|
| 183 |
+
# Pull the frames belonging to those episodes for the next stage.
|
| 184 |
+
frame_rows = (
|
| 185 |
+
frames.search()
|
| 186 |
+
.where(f"episode_index IN ({', '.join(map(str, ep_ids))})", prefilter=True)
|
| 187 |
+
.select(["episode_index", "frame_index", "timestamp", "action", "observation_state"])
|
| 188 |
+
.limit(2000)
|
| 189 |
+
.to_list()
|
| 190 |
+
)
|
| 191 |
+
print(f"{len(ep_rows)} episodes, {len(frame_rows)} frames selected")
|
| 192 |
```
|
| 193 |
|
| 194 |
+
Neither scan reads any video bytes. The MP4 segments live in the blob-encoded `_video_blob` columns and stay on disk until something explicitly asks for them.
|
| 195 |
+
|
| 196 |
+
## Evolve
|
| 197 |
+
|
| 198 |
+
Lance stores each column independently, so a new column can be appended without rewriting the existing data. The lightest form is a SQL expression: derive the new column from columns that already exist, and Lance computes it once and persists it. The example below adds an `action_magnitude` and a `large_action` flag to the frames table, either of which can then be used directly in `where` clauses.
|
| 199 |
+
|
| 200 |
+
> **Note:** Mutations require a local copy of the dataset, since the Hub mount is read-only. See the Materialize-a-subset section at the end of this card for a streaming pattern that downloads only the rows and columns you need.
|
| 201 |
+
|
| 202 |
+
```python
|
| 203 |
+
import lancedb
|
| 204 |
+
|
| 205 |
+
db = lancedb.connect("./lerobot-pusht/data") # local copy required for writes
|
| 206 |
+
frames = db.open_table("frames")
|
| 207 |
+
|
| 208 |
+
frames.add_columns({
|
| 209 |
+
"action_magnitude": "SQRT(action[1] * action[1] + action[2] * action[2])",
|
| 210 |
+
"large_action": "SQRT(action[1] * action[1] + action[2] * action[2]) > 5.0",
|
| 211 |
+
})
|
| 212 |
+
```
|
| 213 |
+
|
| 214 |
+
If the values you want to attach already live in another table (offline reward labels, classifier predictions, learned observation embeddings), merge them in by joining on the appropriate key — `index` for frames or `episode_index` for episodes:
|
| 215 |
+
|
| 216 |
+
```python
|
| 217 |
+
import pyarrow as pa
|
| 218 |
+
|
| 219 |
+
rewards = pa.table({
|
| 220 |
+
"index": pa.array([0, 1, 2]),
|
| 221 |
+
"reward_to_go": pa.array([1.4, 1.3, 1.2]),
|
| 222 |
+
})
|
| 223 |
+
frames.merge(rewards, on="index")
|
| 224 |
+
```
|
| 225 |
+
|
| 226 |
+
The original columns and the inline video blobs are untouched, so existing code that does not reference the new columns continues to work unchanged. For column values that require a Python computation (e.g., running a visual encoder over the decoded video frames), Lance provides a batch-UDF API — see the [Lance data evolution docs](https://lance.org/guide/data_evolution/).
|
| 227 |
+
|
| 228 |
+
## Train
|
| 229 |
+
|
| 230 |
+
A common pattern for vision-conditioned policy training is to pre-extract decoded frame pixels once into a derived LanceDB table — one row per frame, with the per-frame `action` and `observation_state` already joined in — and train against that table with the regular projection-based dataloader. `take_blobs` is the mechanism that makes the extraction step tractable: each episode's MP4 segment is randomly addressable in `episodes.lance` (the `from_timestamp` / `to_timestamp` columns give the segment bounds), so the pass can subset bytes on demand and write decoded frames into a fresh table without an external file store. Other workflows project the `_video_blob` columns from `episodes.lance` directly and decode at the batch boundary, or skip pixels entirely and train a state-only policy on `frames.lance` — the right shape is workload-specific. The actual training loop is the same `Permutation.identity(tbl).select_columns(...)` snippet in every case; only the source table and the column list change.
|
| 231 |
+
|
| 232 |
+
For a state-only policy, the frames table is already in the right shape — no pre-extraction needed:
|
| 233 |
+
|
| 234 |
+
```python
|
| 235 |
+
import lancedb
|
| 236 |
+
from lancedb.permutation import Permutation
|
| 237 |
+
from torch.utils.data import DataLoader
|
| 238 |
+
|
| 239 |
+
db = lancedb.connect("hf://datasets/lance-format/lerobot-pusht-lance/data")
|
| 240 |
+
frames = db.open_table("frames")
|
| 241 |
+
|
| 242 |
+
train_ds = Permutation.identity(frames).select_columns(["observation_state", "action"])
|
| 243 |
+
loader = DataLoader(train_ds, batch_size=128, shuffle=True, num_workers=4)
|
| 244 |
+
```
|
| 245 |
+
|
| 246 |
+
For a vision-conditioned policy, train against a pre-extracted frames-with-pixels table that joins each frame's decoded image to its `action` and `observation_state`:
|
| 247 |
+
|
| 248 |
+
```python
|
| 249 |
+
import lancedb
|
| 250 |
+
from lancedb.permutation import Permutation
|
| 251 |
+
from torch.utils.data import DataLoader
|
| 252 |
+
|
| 253 |
+
db = lancedb.connect("./lerobot-pusht-frames") # local table produced by the one-time extraction
|
| 254 |
+
tbl = db.open_table("train")
|
| 255 |
+
|
| 256 |
+
train_ds = Permutation.identity(tbl).select_columns(["image", "observation_state", "action"])
|
| 257 |
+
loader = DataLoader(train_ds, batch_size=64, shuffle=True, num_workers=4)
|
| 258 |
+
```
|
| 259 |
+
|
| 260 |
+
The inline `_video_blob` storage and `take_blobs` still earn their place outside of the training loop — visualizing an episode in a notebook, sampling for human review, one-off evaluation against a held-out task, and the pre-extraction step itself — but they are not the dataloader.
|
| 261 |
+
|
| 262 |
+
## Versioning
|
| 263 |
+
|
| 264 |
+
Every mutation to a Lance table, whether it adds a column, merges labels, or builds an index, commits a new version. Each of `frames`, `episodes`, and `videos` is versioned independently, so a column added to `frames` does not bump the version of `episodes`. You can list versions and inspect the history directly from the Hub copy; creating new tags requires a local copy since tags are writes.
|
| 265 |
+
|
| 266 |
+
```python
|
| 267 |
+
import lancedb
|
| 268 |
+
|
| 269 |
+
db = lancedb.connect("hf://datasets/lance-format/lerobot-pusht-lance/data")
|
| 270 |
+
frames = db.open_table("frames")
|
| 271 |
+
|
| 272 |
+
print("frames version:", frames.version)
|
| 273 |
+
print("history:", frames.list_versions())
|
| 274 |
+
print("tags:", frames.tags.list())
|
| 275 |
+
```
|
| 276 |
+
|
| 277 |
+
Once you have a local copy, tag the table for reproducibility:
|
| 278 |
+
|
| 279 |
+
```python
|
| 280 |
+
local_db = lancedb.connect("./lerobot-pusht/data")
|
| 281 |
+
local_frames = local_db.open_table("frames")
|
| 282 |
+
local_frames.tags.create("pusht-v1", local_frames.version)
|
| 283 |
+
```
|
| 284 |
+
|
| 285 |
+
Reopen by tag or by version number against either the Hub copy or a local one:
|
| 286 |
+
|
| 287 |
+
```python
|
| 288 |
+
frames_v1 = db.open_table("frames", version="pusht-v1")
|
| 289 |
+
frames_v5 = db.open_table("frames", version=5)
|
| 290 |
+
```
|
| 291 |
+
|
| 292 |
+
Pinning supports two workflows. A policy locked to `pusht-v1` keeps reproducing the same behavior while the dataset evolves in parallel. A training experiment pinned to the same tag can be rerun later against the exact same frames, so changes in metrics reflect model changes rather than data drift.
|
| 293 |
+
|
| 294 |
+
## Materialize a subset
|
| 295 |
+
|
| 296 |
+
Reads from the Hub are lazy, so exploratory queries only transfer the columns and row groups they touch. Mutating operations (Evolve, tag creation, index builds) need a writable backing store, and a training pipeline benefits from a local copy with fast random access into the video blobs. Both can be served by a subset of the dataset rather than the full corpus. The pattern is to stream a filtered query through `.to_batches()` into a new local table; only the projected columns and matching row groups cross the wire, and the bytes never fully materialize in Python memory.
|
| 297 |
+
|
| 298 |
+
```python
|
| 299 |
+
import lancedb
|
| 300 |
+
|
| 301 |
+
remote_db = lancedb.connect("hf://datasets/lance-format/lerobot-pusht-lance/data")
|
| 302 |
+
remote_frames = remote_db.open_table("frames")
|
| 303 |
+
|
| 304 |
+
batches = (
|
| 305 |
+
remote_frames.search()
|
| 306 |
+
.where("task_index = 0 AND episode_index < 50")
|
| 307 |
+
.select(["episode_index", "frame_index", "index", "timestamp", "action", "observation_state"])
|
| 308 |
+
.to_batches()
|
| 309 |
+
)
|
| 310 |
+
|
| 311 |
+
local_db = lancedb.connect("./pusht-task0-subset")
|
| 312 |
+
local_db.create_table("frames", batches)
|
| 313 |
+
```
|
| 314 |
|
| 315 |
+
The resulting `./pusht-task0-subset` is a first-class LanceDB database. Every snippet in the Evolve, Train, and Versioning sections above works against it by swapping `hf://datasets/lance-format/lerobot-pusht-lance/data` for `./pusht-task0-subset`. The same pattern applies to `episodes` and `videos` — narrow each table to the rows your workload needs, and the resulting database stays small enough to index and iterate cheaply.
|
|
|
|
|
|
|
| 316 |
|
| 317 |
## Source & license
|
| 318 |
|