@@ -114,11 +114,11 @@ def _demo_cells(config: RewardsDemoConfig) -> list[tuple[str, str]]:
114114 ("markdown" , intro ),
115115 (
116116 "markdown" ,
117- "## Setup\n \n Install with `pip install daft-physical-ai huggingface_hub matplotlib`, then import." ,
117+ "## Setup\n \n Install with `pip install daft-physical-ai matplotlib`, then import." ,
118118 ),
119119 (
120120 "code" ,
121- "import daft\n from daft import col, lit \n \n from daft_physical_ai.rewards import score_rewards" ,
121+ "from daft import col \n from daft.datasets import lerobot \n \n from daft_physical_ai.rewards import score_rewards" ,
122122 ),
123123 (
124124 "markdown" ,
@@ -136,29 +136,16 @@ def _demo_cells(config: RewardsDemoConfig) -> list[tuple[str, str]]:
136136 ("code" , _SERVER_CELL ),
137137 (
138138 "markdown" ,
139- "## Fetch the episode metadata and video\n \n LeRobot v3 stores episode metadata as "
140- "parquet and concatenates episodes into shared mp4 files. The first metadata and "
141- "video files cover the first episodes, which is all this demo scores." ,
142- ),
143- (
144- "code" ,
145- "from huggingface_hub import hf_hub_download\n "
146- "\n "
147- 'meta_path = hf_hub_download(DATASET, f"{SPLIT}/meta/episodes/chunk-000/file-000.parquet", '
148- 'repo_type="dataset")\n '
149- 'video_path = hf_hub_download(DATASET, f"{SPLIT}/videos/{VIDEO_KEY}/chunk-000/file-000.mp4", '
150- 'repo_type="dataset")' ,
151- ),
152- (
153- "markdown" ,
154- "## Build the episode DataFrame\n \n One row per episode: the task text (from the "
155- "episode's own LeRobot metadata), its length, and where its "
156- "frames live in the video." ,
139+ "## Build the episode DataFrame\n \n One row per episode, straight from Daft's LeRobot "
140+ "reader: `read_episodes` reads the episode metadata and resolves which shared mp4 "
141+ "holds each episode's footage; `include_video_metadata=True` keeps where in that "
142+ "file the episode lives (`from_timestamp`/`to_timestamp`). Everything streams from "
143+ "the Hub - nothing to download first." ,
157144 ),
158145 (
159146 "code" ,
160147 "df = (\n "
161- " daft.read_parquet(meta_path )\n "
148+ ' lerobot.read_episodes(f"hf://datasets/{DATASET}/{SPLIT}", include_video_metadata=True )\n '
162149 ' .sort("episode_index")\n '
163150 " .limit(EPISODES)\n "
164151 " .select(\n "
@@ -167,24 +154,24 @@ def _demo_cells(config: RewardsDemoConfig) -> list[tuple[str, str]]:
167154 ' "length",\n '
168155 ' col(f"videos/{VIDEO_KEY}/from_timestamp").alias("from_ts"),\n '
169156 ' col(f"videos/{VIDEO_KEY}/to_timestamp").alias("to_ts"),\n '
170- ' lit(video_path ).alias("video_path "),\n '
157+ ' col(f"videos/{VIDEO_KEY}/video" ).alias("video "),\n '
171158 " )\n "
172159 ")" ,
173160 ),
174161 (
175162 "markdown" ,
176163 "## Score the episodes\n \n `score_rewards` returns a reward column: it samples "
177164 "`MAX_FRAMES` frames per episode, decodes them from the episode's segment of the "
178- "video, and asks the server for per-frame progress + success. It's a lazy async "
179- "Daft UDF, so nothing runs until we materialize below - and episodes score "
180- "concurrently when they do." ,
165+ "video (streamed through the file handle) , and asks the server for per-frame "
166+ "progress + success. It's a lazy async Daft UDF, so nothing runs until we "
167+ "materialize below - and episodes score concurrently when they do." ,
181168 ),
182169 (
183170 "code" ,
184171 "df = df.with_column(\n "
185172 ' "rewards",\n '
186173 " score_rewards(\n "
187- ' df["task"], df["length"], df["from_ts"], df["to_ts"], df["video_path "],\n '
174+ ' df["task"], df["length"], df["from_ts"], df["to_ts"], df["video "],\n '
188175 " url=ROBOMETER_URL, max_frames=MAX_FRAMES, headers=HEADERS,\n "
189176 " ),\n "
190177 ")" ,
0 commit comments