lakomchik commited on
Commit
65505f2
·
verified ·
1 Parent(s): c087168

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +33 -2
README.md CHANGED
@@ -78,17 +78,48 @@ cd GreenVLA
78
  uv sync # or: pip install -e .
79
  ```
80
 
81
- ### Action Inference (with fine-tuned checkpoint)
82
 
83
  ```python
 
 
84
  from lerobot.common.policies.factory import load_pretrained_policy
 
 
 
 
85
 
 
86
  policy, input_transforms, output_transforms = load_pretrained_policy(
87
- "SberRoboticsCenter/GreenVLA-5b-base",
88
  data_config_name="bridge",
89
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  ```
91
 
 
 
92
  ### VLM Inference (VQA, Pointing, BBox)
93
 
94
  The base model retains full VLM capabilities:
 
78
  uv sync # or: pip install -e .
79
  ```
80
 
81
+ ### Action Inference
82
 
83
  ```python
84
+ import numpy as np
85
+ import torch
86
  from lerobot.common.policies.factory import load_pretrained_policy
87
+ from lerobot.common.utils.torch_observation import (
88
+ move_dict_to_batch_for_inference,
89
+ torch_preprocess_dict_inference,
90
+ )
91
 
92
+ # 1. Load policy and transforms.
93
  policy, input_transforms, output_transforms = load_pretrained_policy(
94
+ "SberRoboticsCenter/GreenVLA-5b-R1-bridge",
95
  data_config_name="bridge",
96
  )
97
+ policy.to("cuda").eval()
98
+
99
+ # 2. Build an observation (replace with real sensor data).
100
+ raw_obs = {
101
+ "observation/state": np.random.rand(8).astype(np.float32), # x y z roll pitch yaw _pad_ gripper
102
+ "observation/image": np.random.randint(0, 256, size=(224, 224, 3), dtype=np.uint8),
103
+ "prompt": "pick up the green block and place it on the plate",
104
+ }
105
+
106
+ # 3. Transform, preprocess, and batch.
107
+ obs = input_transforms(raw_obs)
108
+ obs = torch_preprocess_dict_inference(obs)
109
+ batch = move_dict_to_batch_for_inference(obs, device="cuda")
110
+
111
+ # 4. Predict actions and post-process.
112
+ with torch.inference_mode():
113
+ raw_actions = policy.select_action(batch).cpu().numpy()
114
+
115
+ actions = output_transforms(
116
+ {"actions": raw_actions, "state": batch["state"].cpu().numpy()}
117
+ )["actions"]
118
+ # actions shape: (action_horizon, 7) — [x, y, z, roll, pitch, yaw, gripper]
119
  ```
120
 
121
+ See [`examples/example_inference_bridge.py`](https://github.com/greenvla/GreenVLA/blob/main/examples/example_inference_bridge.py) for the full runnable script with argument parsing.
122
+
123
  ### VLM Inference (VQA, Pointing, BBox)
124
 
125
  The base model retains full VLM capabilities: