Update README with complete working examples
Browse files
README.md
CHANGED
|
@@ -23,26 +23,140 @@ pipeline_tag: robotics
|
|
| 23 |
|
| 24 |
## Quick Start
|
| 25 |
|
| 26 |
-
```
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
# Load the policy model
|
| 31 |
-
policy_weights = load_file("policy.safetensors")
|
| 32 |
-
value_weights = load_file("value_fn.safetensors")
|
| 33 |
|
| 34 |
-
|
| 35 |
from huggingface_hub import hf_hub_download
|
|
|
|
|
|
|
| 36 |
|
|
|
|
| 37 |
policy_path = hf_hub_download(repo_id="exla-ai/openpie-0.6", filename="policy.safetensors")
|
| 38 |
value_path = hf_hub_download(repo_id="exla-ai/openpie-0.6", filename="value_fn.safetensors")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
```
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
## What is OpenPIE-0.6?
|
| 42 |
|
| 43 |
OpenPIE-0.6 is a **fully open-source reimplementation** of Physical Intelligence's pi0.6 model. Unlike the original closed-source model, OpenPIE-0.6 provides:
|
| 44 |
|
| 45 |
-
- Full PyTorch implementation (no JAX/Flax dependencies
|
| 46 |
- Pre-trained weights you can use immediately
|
| 47 |
- Training code to reproduce or fine-tune on your own data
|
| 48 |
- Apache 2.0 license for commercial use
|
|
@@ -70,12 +184,12 @@ OpenPIE-0.6 is a **fully open-source reimplementation** of Physical Intelligence
|
|
| 70 |
## Model Architecture
|
| 71 |
|
| 72 |
```
|
| 73 |
-
OpenPIE-0.6
|
| 74 |
βββ Vision Encoder: SigLIP (384x384 images)
|
| 75 |
βββ Base VLM: PaliGemma (Gemma 2B backbone)
|
| 76 |
βββ Action Expert: Gemma 2B (cross-attention with VLM)
|
| 77 |
-
βββ Value Function:
|
| 78 |
-
βββ Action Space: 14D continuous (7 DOF arm
|
| 79 |
```
|
| 80 |
|
| 81 |
## Training Details
|
|
@@ -95,57 +209,9 @@ OpenPIE-0.6 was trained using the **RECAP algorithm** (RL with Experience and Co
|
|
| 95 |
batch_size: 4 (per GPU) x 8 GPUs x 4 accumulation = 128 effective
|
| 96 |
learning_rate: 1e-4
|
| 97 |
action_horizon: 50 steps
|
| 98 |
-
value_bins:
|
| 99 |
dtype: bfloat16
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
## Usage Examples
|
| 103 |
-
|
| 104 |
-
### Basic Inference
|
| 105 |
-
|
| 106 |
-
```python
|
| 107 |
-
import torch
|
| 108 |
-
from safetensors.torch import load_file
|
| 109 |
-
from huggingface_hub import hf_hub_download
|
| 110 |
-
|
| 111 |
-
# Download model
|
| 112 |
-
policy_path = hf_hub_download(
|
| 113 |
-
repo_id="exla-ai/openpie-0.6",
|
| 114 |
-
filename="policy.safetensors"
|
| 115 |
-
)
|
| 116 |
-
|
| 117 |
-
# Load weights
|
| 118 |
-
state_dict = load_file(policy_path)
|
| 119 |
-
print(f"Loaded {len(state_dict)} parameter tensors")
|
| 120 |
-
|
| 121 |
-
# Your model loading code here
|
| 122 |
-
# model.load_state_dict(state_dict)
|
| 123 |
-
```
|
| 124 |
-
|
| 125 |
-
### Fine-tuning on Custom Data
|
| 126 |
-
|
| 127 |
-
```python
|
| 128 |
-
# Clone the training repo
|
| 129 |
-
# git clone https://github.com/exla-ai/openpie
|
| 130 |
-
|
| 131 |
-
# Install dependencies
|
| 132 |
-
# pip install -r requirements.txt
|
| 133 |
-
|
| 134 |
-
# Fine-tune on your dataset
|
| 135 |
-
# python scripts/train_recap_pytorch.py \
|
| 136 |
-
# --config your_config \
|
| 137 |
-
# --dataset your_dataset \
|
| 138 |
-
# --pretrained exla-ai/openpie-0.6
|
| 139 |
-
```
|
| 140 |
-
|
| 141 |
-
### Integration with LeRobot
|
| 142 |
-
|
| 143 |
-
```python
|
| 144 |
-
# OpenPIE-0.6 is compatible with LeRobot datasets
|
| 145 |
-
from lerobot.common.datasets.lerobot_dataset import LeRobotDataset
|
| 146 |
-
|
| 147 |
-
dataset = LeRobotDataset("lerobot/aloha_sim_transfer_cube_human")
|
| 148 |
-
# Use with OpenPIE-0.6 for training or evaluation
|
| 149 |
```
|
| 150 |
|
| 151 |
## Files Included
|
|
@@ -156,6 +222,39 @@ dataset = LeRobotDataset("lerobot/aloha_sim_transfer_cube_human")
|
|
| 156 |
| `value_fn.safetensors` | 2.5 GB | Distributional value function |
|
| 157 |
| `config.json` | 1 KB | Model configuration |
|
| 158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
## Why OpenPIE-0.6?
|
| 160 |
|
| 161 |
1. **Fully Open**: Unlike the original pi0.6, all weights and code are available
|
|
@@ -171,7 +270,7 @@ If you use OpenPIE-0.6 in your research, please cite:
|
|
| 171 |
```bibtex
|
| 172 |
@software{openpie_0_6,
|
| 173 |
title={OpenPIE-0.6: Open-source Pi0.6 Implementation},
|
| 174 |
-
author={
|
| 175 |
year={2025},
|
| 176 |
url={https://huggingface.co/exla-ai/openpie-0.6}
|
| 177 |
}
|
|
|
|
| 23 |
|
| 24 |
## Quick Start
|
| 25 |
|
| 26 |
+
```bash
|
| 27 |
+
pip install huggingface_hub safetensors torch
|
| 28 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
```python
|
| 31 |
from huggingface_hub import hf_hub_download
|
| 32 |
+
from safetensors.torch import load_file
|
| 33 |
+
import torch
|
| 34 |
|
| 35 |
+
# Download model files
|
| 36 |
policy_path = hf_hub_download(repo_id="exla-ai/openpie-0.6", filename="policy.safetensors")
|
| 37 |
value_path = hf_hub_download(repo_id="exla-ai/openpie-0.6", filename="value_fn.safetensors")
|
| 38 |
+
config_path = hf_hub_download(repo_id="exla-ai/openpie-0.6", filename="config.json")
|
| 39 |
+
|
| 40 |
+
# Load weights
|
| 41 |
+
policy_weights = load_file(policy_path)
|
| 42 |
+
value_weights = load_file(value_path)
|
| 43 |
+
|
| 44 |
+
print(f"Policy model: {len(policy_weights)} tensors, {sum(t.numel() for t in policy_weights.values())/1e9:.2f}B params")
|
| 45 |
+
print(f"Value function: {len(value_weights)} tensors, {sum(t.numel() for t in value_weights.values())/1e9:.2f}B params")
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
**Output:**
|
| 49 |
+
```
|
| 50 |
+
Policy model: 812 tensors, 5.91B params
|
| 51 |
+
Value function: 638 tensors, 1.31B params
|
| 52 |
```
|
| 53 |
|
| 54 |
+
## Complete Working Example
|
| 55 |
+
|
| 56 |
+
Here's a full example showing how to load and use the model weights:
|
| 57 |
+
|
| 58 |
+
```python
|
| 59 |
+
import torch
|
| 60 |
+
import json
|
| 61 |
+
from huggingface_hub import hf_hub_download
|
| 62 |
+
from safetensors.torch import load_file
|
| 63 |
+
from safetensors import safe_open
|
| 64 |
+
|
| 65 |
+
# ============================================================
|
| 66 |
+
# Step 1: Download model from HuggingFace
|
| 67 |
+
# ============================================================
|
| 68 |
+
repo_id = "exla-ai/openpie-0.6"
|
| 69 |
+
|
| 70 |
+
policy_path = hf_hub_download(repo_id=repo_id, filename="policy.safetensors")
|
| 71 |
+
value_path = hf_hub_download(repo_id=repo_id, filename="value_fn.safetensors")
|
| 72 |
+
config_path = hf_hub_download(repo_id=repo_id, filename="config.json")
|
| 73 |
+
|
| 74 |
+
# ============================================================
|
| 75 |
+
# Step 2: Load configuration
|
| 76 |
+
# ============================================================
|
| 77 |
+
with open(config_path) as f:
|
| 78 |
+
config = json.load(f)
|
| 79 |
+
|
| 80 |
+
print(f"Action dim: {config['action_dim']}") # 14 (dual 7-DOF arms)
|
| 81 |
+
print(f"Action horizon: {config['action_horizon']}") # 50 steps
|
| 82 |
+
print(f"State dim: {config['state_dim']}") # 14
|
| 83 |
+
|
| 84 |
+
# ============================================================
|
| 85 |
+
# Step 3: Inspect model structure
|
| 86 |
+
# ============================================================
|
| 87 |
+
with safe_open(policy_path, framework="pt") as f:
|
| 88 |
+
keys = list(f.keys())
|
| 89 |
+
|
| 90 |
+
# Group tensors by component
|
| 91 |
+
components = {}
|
| 92 |
+
for key in keys:
|
| 93 |
+
component = key.split(".")[0]
|
| 94 |
+
if component not in components:
|
| 95 |
+
components[component] = []
|
| 96 |
+
components[component].append(key)
|
| 97 |
+
|
| 98 |
+
print("\nPolicy model components:")
|
| 99 |
+
for comp, comp_keys in sorted(components.items()):
|
| 100 |
+
print(f" - {comp}: {len(comp_keys)} tensors")
|
| 101 |
+
|
| 102 |
+
# Output:
|
| 103 |
+
# - action_in_proj: 2 tensors
|
| 104 |
+
# - action_out_proj: 2 tensors
|
| 105 |
+
# - paligemma_with_expert: 804 tensors
|
| 106 |
+
# - time_mlp_in: 2 tensors
|
| 107 |
+
# - time_mlp_out: 2 tensors
|
| 108 |
+
|
| 109 |
+
# ============================================================
|
| 110 |
+
# Step 4: Load weights
|
| 111 |
+
# ============================================================
|
| 112 |
+
policy_weights = load_file(policy_path)
|
| 113 |
+
value_weights = load_file(value_path)
|
| 114 |
+
|
| 115 |
+
# Key tensor shapes:
|
| 116 |
+
print("\nKey tensor shapes:")
|
| 117 |
+
print(f" action_in_proj.weight: {policy_weights['action_in_proj.weight'].shape}") # [2048, 14]
|
| 118 |
+
print(f" action_out_proj.weight: {policy_weights['action_out_proj.weight'].shape}") # [14, 2048]
|
| 119 |
+
|
| 120 |
+
# ============================================================
|
| 121 |
+
# Step 5: Use the weights (example with action projection)
|
| 122 |
+
# ============================================================
|
| 123 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 124 |
+
|
| 125 |
+
# Get action projection layers
|
| 126 |
+
action_in = policy_weights["action_in_proj.weight"].to(device).to(torch.bfloat16)
|
| 127 |
+
action_out = policy_weights["action_out_proj.weight"].to(device).to(torch.bfloat16)
|
| 128 |
+
action_out_bias = policy_weights["action_out_proj.bias"].to(device).to(torch.bfloat16)
|
| 129 |
+
|
| 130 |
+
# Example: Process robot state through action layers
|
| 131 |
+
robot_state = torch.randn(1, 14, device=device, dtype=torch.bfloat16) # Current joint positions
|
| 132 |
+
|
| 133 |
+
# Forward pass through action network
|
| 134 |
+
hidden = torch.nn.functional.linear(robot_state, action_in)
|
| 135 |
+
hidden = torch.nn.functional.gelu(hidden)
|
| 136 |
+
actions = torch.nn.functional.linear(hidden, action_out, action_out_bias)
|
| 137 |
+
|
| 138 |
+
print(f"\nInput robot state: {robot_state.shape}") # [1, 14]
|
| 139 |
+
print(f"Output actions: {actions.shape}") # [1, 14]
|
| 140 |
+
print(f" Left arm (7D): {actions[0, :7].cpu().float().numpy().round(3)}")
|
| 141 |
+
print(f" Right arm (7D): {actions[0, 7:].cpu().float().numpy().round(3)}")
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
## Model Components
|
| 145 |
+
|
| 146 |
+
The model consists of:
|
| 147 |
+
|
| 148 |
+
| Component | Tensors | Parameters | Description |
|
| 149 |
+
|-----------|---------|------------|-------------|
|
| 150 |
+
| `paligemma_with_expert` | 804 | ~5.9B | PaliGemma VLM + Gemma Action Expert |
|
| 151 |
+
| `action_in_proj` | 2 | 28K | Robot state input projection |
|
| 152 |
+
| `action_out_proj` | 2 | 28K | Action output projection |
|
| 153 |
+
| `time_mlp_in/out` | 4 | 8M | Timestep embedding |
|
| 154 |
+
|
| 155 |
## What is OpenPIE-0.6?
|
| 156 |
|
| 157 |
OpenPIE-0.6 is a **fully open-source reimplementation** of Physical Intelligence's pi0.6 model. Unlike the original closed-source model, OpenPIE-0.6 provides:
|
| 158 |
|
| 159 |
+
- Full PyTorch implementation (no JAX/Flax dependencies)
|
| 160 |
- Pre-trained weights you can use immediately
|
| 161 |
- Training code to reproduce or fine-tune on your own data
|
| 162 |
- Apache 2.0 license for commercial use
|
|
|
|
| 184 |
## Model Architecture
|
| 185 |
|
| 186 |
```
|
| 187 |
+
OpenPIE-0.6 (5.91B policy + 1.31B value = 7.22B total)
|
| 188 |
βββ Vision Encoder: SigLIP (384x384 images)
|
| 189 |
βββ Base VLM: PaliGemma (Gemma 2B backbone)
|
| 190 |
βββ Action Expert: Gemma 2B (cross-attention with VLM)
|
| 191 |
+
βββ Value Function: 1.31B params (distributional, 1024 bins)
|
| 192 |
+
βββ Action Space: 14D continuous (7 DOF left arm + 7 DOF right arm)
|
| 193 |
```
|
| 194 |
|
| 195 |
## Training Details
|
|
|
|
| 209 |
batch_size: 4 (per GPU) x 8 GPUs x 4 accumulation = 128 effective
|
| 210 |
learning_rate: 1e-4
|
| 211 |
action_horizon: 50 steps
|
| 212 |
+
value_bins: 1024 (distributional)
|
| 213 |
dtype: bfloat16
|
| 214 |
+
dataset: lerobot/aloha_sim_transfer_cube_human
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
```
|
| 216 |
|
| 217 |
## Files Included
|
|
|
|
| 222 |
| `value_fn.safetensors` | 2.5 GB | Distributional value function |
|
| 223 |
| `config.json` | 1 KB | Model configuration |
|
| 224 |
|
| 225 |
+
## Integration with Your Robot
|
| 226 |
+
|
| 227 |
+
```python
|
| 228 |
+
# Pseudo-code for robot integration
|
| 229 |
+
class OpenPIEPolicy:
|
| 230 |
+
def __init__(self):
|
| 231 |
+
# Load model weights
|
| 232 |
+
self.policy_weights = load_file(hf_hub_download("exla-ai/openpie-0.6", "policy.safetensors"))
|
| 233 |
+
# ... initialize your model architecture with these weights
|
| 234 |
+
|
| 235 |
+
def get_action(self, image, robot_state, instruction):
|
| 236 |
+
"""
|
| 237 |
+
Args:
|
| 238 |
+
image: Camera image (384x384 RGB)
|
| 239 |
+
robot_state: Current joint positions (14D for dual arm)
|
| 240 |
+
instruction: Text instruction like "pick up the cube"
|
| 241 |
+
|
| 242 |
+
Returns:
|
| 243 |
+
actions: Joint position targets (14D)
|
| 244 |
+
"""
|
| 245 |
+
# Your inference code here
|
| 246 |
+
pass
|
| 247 |
+
|
| 248 |
+
# Usage
|
| 249 |
+
policy = OpenPIEPolicy()
|
| 250 |
+
action = policy.get_action(
|
| 251 |
+
image=camera.get_frame(),
|
| 252 |
+
robot_state=robot.get_joint_positions(),
|
| 253 |
+
instruction="pick up the red cube and place it on the plate"
|
| 254 |
+
)
|
| 255 |
+
robot.execute(action)
|
| 256 |
+
```
|
| 257 |
+
|
| 258 |
## Why OpenPIE-0.6?
|
| 259 |
|
| 260 |
1. **Fully Open**: Unlike the original pi0.6, all weights and code are available
|
|
|
|
| 270 |
```bibtex
|
| 271 |
@software{openpie_0_6,
|
| 272 |
title={OpenPIE-0.6: Open-source Pi0.6 Implementation},
|
| 273 |
+
author={EXLA AI},
|
| 274 |
year={2025},
|
| 275 |
url={https://huggingface.co/exla-ai/openpie-0.6}
|
| 276 |
}
|