dwko's picture
Update README.md
0c5a356 verified
|
Raw
History Blame Contribute Delete
8.28 kB
---
license: apache-2.0
base_model:
- nvidia/Alpamayo-R1-10B
---
nvidia/Alpamayo-R1-10B 4bit Model.
์ด๋ชจ๋ธ์€ ์ž์œจ์ฃผํ–‰ ์ค‘ ์ˆ˜์ง‘๋œ ๋ฐ์ดํ„ฐ๋กœ ์ด๋ฒคํŠธ๋ฅผ ์˜ˆ์ธกํ•˜๋Š” ์šฉ๋„๋กœ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ž์œจ์ฃผํ–‰์„ ํ•˜๋Š”๊ฒŒ ์•„๋‹ˆ๋ผ ์ž์œจ์ฃผํ–‰ ์ค‘ ํŠน์ • ์ƒํ™ฉ์ด ๋ฐœ์ƒํ•  ๊ฒƒ์„ ์•Œ๋ ค์ฃผ๋Š” ๊ธฐ๋Šฅ์„ ํ•ฉ๋‹ˆ๋‹ค.
```Runinfo
model download ./Alpamayo-R1-10B-4bit
GPU 12G/16G Memory Run able
12G Memory is num_frames is 1 ~ 8, over OOM
Transformers is 4.57.5 ( 5.0.0rc not run)
nvidia/Alpamayo-R1-10B ์ด ๋Œ€์šฉ๋Ÿ‰ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์š”๊ตฌํ•˜๊ณ  4bit ๋กœ ๋กœ๋”ฉํ•˜์—ฌ ์ €์žฅํ•œ ๋ชจ๋ธ์ž…๋‹ˆ๋‹ค.
12G ์—์„œ๋„ ์‹คํ–‰๊ฐ€๋Šฅํ•ด์กŒ์Šต๋‹ˆ๋‹ค๋งŒ ์ฃผ์–ด์ง€๋Š” ํ”„๋ ˆ์ž„์ˆ˜๋Š” 1~8์ •๋„, ๊ทธ ์ด์ƒ์ด๋ฉด OOM์ด ๋–จ์–ด์ง‘๋‹ˆ๋‹ค.
ํŠธ๋žœ์Šคํฌ๋จธ ๋ฒ„์ „ 5.0.0rc์—์„œ๋Š” ๋™์ž‘ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
git clone https://github.com/NVlabs/alpamayo ํ•˜๊ณ 
cd alpamayo
pip install . ๋กœ ์„ค์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค๋งŒ
pyproject.toml์„ ์ˆ˜์ •ํ•˜๋Š”๊ฒŒ ์ข‹์Šต๋‹ˆ๋‹ค.
python 3.13์„ ์‚ฌ์šฉํ•˜๋ฉด requires-python = "==3.13.*"
transformers ์™€ torch๋ฅผ ๋ผ์ธ์„ ์ œ๊ฑฐํ•˜๊ณ  ์„ค์น˜ํ•˜๋ฉด ์„ค์น˜๋œ ๋ฒ„์ „์ด ๊ต์ฒด๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
```
-----------------------------------
```python
import torch
import numpy as np
from alpamayo_r1.models.alpamayo_r1 import AlpamayoR1
from alpamayo_r1.load_physical_aiavdataset import load_physical_aiavdataset
from alpamayo_r1 import helper
model_path = "Alpamayo-R1-10B-4bit"
model = AlpamayoR1.from_pretrained(model_path, dtype=torch.bfloat16).to("cuda")
processor = helper.get_processor(model.tokenizer)
clip_id = "030c760c-ae38-49aa-9ad8-f5650a545d26"
print(f"Loading dataset for clip_id: {clip_id}...")
#need set access token or huggingface-cli login...
data = load_physical_aiavdataset(clip_id, t0_us=15_100_000,num_frames=1)
print("Dataset loaded.")
messages = helper.create_message(data["image_frames"].flatten(0, 1))
inputs = processor.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=False,
continue_final_message=True,
return_dict=True,
return_tensors="pt",
)
model_inputs = {
"tokenized_data": inputs,
"ego_history_xyz": data["ego_history_xyz"],
"ego_history_rot": data["ego_history_rot"],
}
model_inputs = helper.to_device(model_inputs, "cuda")
torch.cuda.manual_seed_all(42)
with torch.autocast("cuda", dtype=torch.bfloat16):
pred_xyz, pred_rot, extra = model.sample_trajectories_from_data_with_vlm_rollout(
data=model_inputs,
top_p=0.98,
temperature=0.6,
num_traj_samples=1, # Feel free to raise this for more output trajectories and CoC traces.
max_generation_length=256,
return_extra=True,
)
print("Chain-of-Causation (per trajectory):\n", extra["cot"][0])
gt_xy = data["ego_future_xyz"].cpu()[0, 0, :, :2].T.numpy()
pred_xy = pred_xyz.cpu().numpy()[0, 0, :, :, :2].transpose(0, 2, 1)
diff = np.linalg.norm(pred_xy - gt_xy[None, ...], axis=1).mean(-1)
min_ade = diff.min()
print("minADE:", min_ade, "meters")
print(
"Note: VLA-reasoning models produce nondeterministic outputs due to trajectory sampling, "
"hardware differences, etc. With num_traj_samples=1 (set for GPU memory compatibility), "
"variance in minADE is expected. For visual sanity checks, see notebooks/inference.ipynb"
)
```
--------------------
```Result:
Chain-of-Causation (per trajectory):
[['Nudge to the left to pass the stopped truck encroaching into the lane.']]
minADE: 1.7749525 meters
Note: VLA-reasoning models produce nondeterministic outputs due to trajectory sampling, hardware differences, etc. With num_traj_samples=1 (set for GPU memory compatibility), variance in minADE is expected. For visual sanity checks, see notebooks/inference.ipynb
```
๋‚˜๋Š” 1์žฅ์˜ ์ด๋ฏธ์ง€๋กœ ํŒ๋…ํ•˜๋Š” ๊ฒƒ์„ ํ…Œ์ŠคํŠธ ํ•˜๋ ค๊ณ  ์•„๋ž˜์™€ ๊ฐ™์€ ์˜ˆ์ œ๋ฅผ ๋งŒ๋“ค์—ˆ๋‹ค.
๋ฐ์ดํ„ฐ ๋กœ๋”ฉ ์—†์ด ๊ธฐ๋ณธ ์ดˆ๊ธฐํ™”๋ฅผ ํ•˜์—ฌ ์‹œ์ž‘์ ์—์„œ ์‹œ์ž‘ํ•˜๋Š” ๊ฒƒ์—์„œ ์‹œ์ž‘ํ•œ๋‹ค.
๊ตฌ๋™ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์ตœ์†Œ 12G ์ด์ƒ์ธ GPU์นด๋“œ๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๊ณ , ์‘๋‹ต์†๋„ ๋„ ๊ฝค ์ง€์—ฐ์ด ๊ฑธ๋ ค
์‹ค์ œ ์ž๋™์ฐจ์— ์ ์šฉํ•˜๊ธฐ์— ๋ฌด๋ฆฌ์ธ๊ฒƒ ๊ฐ™๋‹ค.
```python
#ZeroTime init Base Image(1 photo on load image)
import torch
import numpy as np
from PIL import Image
from alpamayo_r1.models.alpamayo_r1 import AlpamayoR1
from alpamayo_r1.load_physical_aiavdataset import load_physical_aiavdataset
from alpamayo_r1 import helper
num_history_steps = 16 # ๊ณผ๊ฑฐ ์Šคํ… ์ˆ˜
num_future_steps = 64 # ๋ฏธ๋ž˜ ์Šคํ… ์ˆ˜
# ๋”๋ฏธ ์œ„์น˜ ๋ฐ์ดํ„ฐ (xyz ์ขŒํ‘œ)
ego_history_xyz = torch.zeros((1, 1, num_history_steps, 3)) # (batch, agent, steps, xyz)
ego_future_xyz = torch.zeros((1, 1, num_future_steps, 3))
# ๋”๋ฏธ ํšŒ์ „ ๋ฐ์ดํ„ฐ (3x3 ํšŒ์ „ํ–‰๋ ฌ)
ego_history_rot = torch.eye(3).repeat(1, 1, num_history_steps, 1, 1) # (1,1,steps,3,3)
ego_future_rot = torch.eye(3).repeat(1, 1, num_future_steps, 1, 1)
print("ego_history_xyz:", ego_history_xyz.shape)
print("ego_future_xyz:", ego_future_xyz.shape)
print("ego_history_rot:", ego_history_rot.shape)
print("ego_future_rot:", ego_future_rot.shape)
N_cameras = 1
camera_indices = torch.arange(N_cameras, dtype=torch.long) # (N_cameras,) - long ํƒ€์ž… ๋ช…์‹œ
data={
"camera_indices": camera_indices, # (N_cameras,)
"ego_history_xyz": ego_history_xyz, # (1, 1, num_history_steps, 3)
"ego_history_rot": ego_history_rot, # (1, 1, num_history_steps, 3, 3)
"ego_future_xyz": ego_future_xyz, # (1, 1, num_future_steps, 3)
"ego_future_rot": ego_future_rot, # (1, 1, num_future_steps, 3, 3)
# "relative_timestamps": relative_timestamps, # (N_cameras, num_frames)
# "absolute_timestamps": absolute_timestamps # (N_cameras, num_frames)
}
img_path = "IMG_20260116_065921.jpg"
# ์˜ˆ์ธกํ•˜๊ณ  ์‹ถ์€ JPG ํŒŒ์ผ ๊ฒฝ๋กœ
image = Image.open(img_path).convert("RGB")
# helper.create_message๋Š” tensor ์ž…๋ ฅ์„ ๊ธฐ๋Œ€ํ•˜๋ฏ€๋กœ ๋ณ€ํ™˜
# PIL Image๋ฅผ numpy array๋กœ ๋ณ€ํ™˜ ํ›„ float32๋กœ ๋ณ€ํ™˜
image_array = np.array(image).astype(np.float32) / 255.0 # 0-1 ๋ฒ”์œ„๋กœ ์ •๊ทœํ™”
image_tensor = torch.from_numpy(image_array).unsqueeze(0) # [batch, H, W, C]
# ๋ฉ”์‹œ์ง€ ์ƒ์„ฑ
messages = helper.create_message(image_tensor)
# Example clip ID
model_path = "Alpamayo-R1-10B-4bit"
model = AlpamayoR1.from_pretrained(model_path, dtype=torch.bfloat16).to("cuda")
processor = helper.get_processor(model.tokenizer)
# ์„ค์ •๊ฐ’
inputs = processor.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=False,
continue_final_message=True,
return_dict=True,
return_tensors="pt",
)
model_inputs = {
"tokenized_data": inputs,
"ego_history_xyz": data["ego_history_xyz"],
"ego_history_rot": data["ego_history_rot"],
}
model_inputs = helper.to_device(model_inputs, "cuda")
torch.cuda.manual_seed_all(42)
with torch.autocast("cuda", dtype=torch.bfloat16):
pred_xyz, pred_rot, extra = model.sample_trajectories_from_data_with_vlm_rollout(
data=model_inputs,
top_p=0.98,
temperature=0.6,
num_traj_samples=1, # Feel free to raise this for more output trajectories and CoC traces.
max_generation_length=256,
return_extra=True,
)
# the size is [batch_size, num_traj_sets, num_traj_samples]
print("Chain-of-Causation (per trajectory):\n", extra["cot"][0])
gt_xy = data["ego_future_xyz"].cpu()[0, 0, :, :2].T.numpy()
pred_xy = pred_xyz.cpu().numpy()[0, 0, :, :, :2].transpose(0, 2, 1)
diff = np.linalg.norm(pred_xy - gt_xy[None, ...], axis=1).mean(-1)
min_ade = diff.min()
print("minADE:", min_ade, "meters")
print(
"Note: VLA-reasoning models produce nondeterministic outputs due to trajectory sampling, "
"hardware differences, etc. With num_traj_samples=1 (set for GPU memory compatibility), "
"variance in minADE is expected. For visual sanity checks, see notebooks/inference.ipynb"
)
```
```output
Chain-of-Causation (per trajectory):
[['Keep lane to continue driving since the lane ahead is clear.']]
minADE: 0.55852604 meters
Note: VLA-reasoning models produce nondeterministic outputs due to trajectory sampling, hardware differences, etc. With num_traj_samples=1 (set for GPU memory compatibility), variance in minADE is expected. For visual sanity checks, see notebooks/inference.ipynb
```