File size: 1,809 Bytes
625a281
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import json
import pandas as pd
from pathlib import Path

# Path to your dataset
DATASET_ROOT = Path(r"C:\Users\h28176\OneDrive - Centria ammattikorkeakoulu Oy\python_projects\RTDE_python\Ur5e_RTDE\lerobot_dataset_ur5e_dualcam")

# --- Update info.json to v3.0 ---
info_path = DATASET_ROOT / "meta" / "info.json"
with open(info_path, "r") as f:
    info = json.load(f)

info["codebase_version"] = "v3.0"

# Include your desired features
info["features"] = {
    "observation.images.wrist": {
        "dtype": "video",
        "shape": [480, 640, 3],
        "info": {"video.fps": 15, "video.codec": "h264"},
    },
    "observation.images.context": {
        "dtype": "video",
        "shape": [480, 640, 3],
        "info": {"video.fps": 15, "video.codec": "h264"},
    },
    "observation.state": {"dtype": "float32", "shape": [6]},
    "action": {"dtype": "float32", "shape": [6]},
    "timestamp": {"dtype": "float32", "shape": []},
    "frame_index": {"dtype": "int64", "shape": []},
    "episode_index": {"dtype": "int64", "shape": []},
    "index": {"dtype": "int64", "shape": []},
    "task_index": {"dtype": "int64", "shape": []},
}

with open(info_path, "w") as f:
    json.dump(info, f, indent=4)

print("✅ Updated info.json to v3.0 with your desired features.")


# --- Add missing columns to each parquet if needed ---
data_dir = DATASET_ROOT / "data" / "chunk-000"
for pq in data_dir.glob("*.parquet"):
    df = pd.read_parquet(pq)
    if "index" not in df.columns:
        df["index"] = range(len(df))
    if "task_index" not in df.columns:
        df["task_index"] = 0  # Default single task dataset
    df.to_parquet(pq, index=False)
    print(f"🧩 Updated {pq.name}")

print("🎉 Dataset fully converted to LeRobot v3.0 structure.")