File size: 1,077 Bytes
ad17a83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""Load normalized interactions and individual LeRobot exports from the Hub."""
import json
import pathlib
from datasets import load_dataset
from huggingface_hub import snapshot_download


def load_interactions(stream='policy', split='train'):
    return load_dataset(f'LV-Robotics-Lab/pi-embodied-{stream}-interactions', split=split)


def as_chat(row):
    """OpenAI-style messages, including tool calls and remote image URLs."""
    return json.loads(row['messages_json'])


def load_execution_export(name, revision='main'):
    from lerobot.datasets.lerobot_dataset import LeRobotDataset
    repo = 'LV-Robotics-Lab/pi-embodied-policy-interactions'
    snapshot = pathlib.Path(snapshot_download(repo, repo_type='dataset', revision=revision,
                                              allow_patterns=[f'lerobot/{name}/**']))
    root = snapshot/'lerobot'/name
    if not (root/'meta/info.json').exists():
        raise FileNotFoundError(f'Unknown execution export: {name}')
    return LeRobotDataset(repo_id=repo, root=root, download_videos=False)