Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,70 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
---
|
| 4 |
+
nvidia/Alpamayo-R1-10B 4bit Model.
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
---- model download ./Alpamayo-R1-10B-4bit
|
| 8 |
+
---- GPU 12G Memory Run abble, num_frames is 1 ~ 8, over OOM..
|
| 9 |
+
|
| 10 |
+
import torch
|
| 11 |
+
import numpy as np
|
| 12 |
+
|
| 13 |
+
from alpamayo_r1.models.alpamayo_r1 import AlpamayoR1
|
| 14 |
+
from alpamayo_r1.load_physical_aiavdataset import load_physical_aiavdataset
|
| 15 |
+
from alpamayo_r1 import helper
|
| 16 |
+
|
| 17 |
+
# Example clip ID
|
| 18 |
+
model_path = "Alpamayo-R1-10B-4bit"
|
| 19 |
+
model = AlpamayoR1.from_pretrained(model_path, dtype=torch.bfloat16).to("cuda")
|
| 20 |
+
processor = helper.get_processor(model.tokenizer)
|
| 21 |
+
|
| 22 |
+
# Example clip ID
|
| 23 |
+
clip_id = "030c760c-ae38-49aa-9ad8-f5650a545d26"
|
| 24 |
+
print(f"Loading dataset for clip_id: {clip_id}...")
|
| 25 |
+
data = load_physical_aiavdataset(clip_id, t0_us=15_100_000,num_frames=1)
|
| 26 |
+
print(f"{data}")
|
| 27 |
+
print("Dataset loaded.")
|
| 28 |
+
messages = helper.create_message(data["image_frames"].flatten(0, 1))
|
| 29 |
+
|
| 30 |
+
inputs = processor.apply_chat_template(
|
| 31 |
+
messages,
|
| 32 |
+
tokenize=True,
|
| 33 |
+
add_generation_prompt=False,
|
| 34 |
+
continue_final_message=True,
|
| 35 |
+
return_dict=True,
|
| 36 |
+
return_tensors="pt",
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
model_inputs = {
|
| 40 |
+
"tokenized_data": inputs,
|
| 41 |
+
"ego_history_xyz": data["ego_history_xyz"],
|
| 42 |
+
"ego_history_rot": data["ego_history_rot"],
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
model_inputs = helper.to_device(model_inputs, "cuda")
|
| 46 |
+
|
| 47 |
+
torch.cuda.manual_seed_all(42)
|
| 48 |
+
with torch.autocast("cuda", dtype=torch.bfloat16):
|
| 49 |
+
pred_xyz, pred_rot, extra = model.sample_trajectories_from_data_with_vlm_rollout(
|
| 50 |
+
data=model_inputs,
|
| 51 |
+
top_p=0.98,
|
| 52 |
+
temperature=0.6,
|
| 53 |
+
num_traj_samples=1, # Feel free to raise this for more output trajectories and CoC traces.
|
| 54 |
+
max_generation_length=256,
|
| 55 |
+
return_extra=True,
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
# the size is [batch_size, num_traj_sets, num_traj_samples]
|
| 59 |
+
print("Chain-of-Causation (per trajectory):\n", extra["cot"][0])
|
| 60 |
+
|
| 61 |
+
gt_xy = data["ego_future_xyz"].cpu()[0, 0, :, :2].T.numpy()
|
| 62 |
+
pred_xy = pred_xyz.cpu().numpy()[0, 0, :, :, :2].transpose(0, 2, 1)
|
| 63 |
+
diff = np.linalg.norm(pred_xy - gt_xy[None, ...], axis=1).mean(-1)
|
| 64 |
+
min_ade = diff.min()
|
| 65 |
+
print("minADE:", min_ade, "meters")
|
| 66 |
+
print(
|
| 67 |
+
"Note: VLA-reasoning models produce nondeterministic outputs due to trajectory sampling, "
|
| 68 |
+
"hardware differences, etc. With num_traj_samples=1 (set for GPU memory compatibility), "
|
| 69 |
+
"variance in minADE is expected. For visual sanity checks, see notebooks/inference.ipynb"
|
| 70 |
+
)
|