mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-24 04:59:47 +00:00
make it work
This commit is contained in:
Binary file not shown.
@@ -1,5 +1,5 @@
|
|||||||
lerobot-eval \
|
lerobot-eval \
|
||||||
--policy.path="/raid/jade/models/xvla-lib" \
|
--policy.path="/raid/jade/models/xvla-libero-new_migrated2" \
|
||||||
--env.type=libero \
|
--env.type=libero \
|
||||||
--env.task=libero_spatial \
|
--env.task=libero_spatial \
|
||||||
--env.control_mode=absolute \
|
--env.control_mode=absolute \
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
@@ -244,7 +244,7 @@ class LiberoEnv(gym.Env):
|
|||||||
eef_quat = raw_obs.get("robot0_eef_quat")
|
eef_quat = raw_obs.get("robot0_eef_quat")
|
||||||
|
|
||||||
# rotation matrix from controller
|
# rotation matrix from controller
|
||||||
eef_mat = self._env.robots[0].controller.ee_ori_mat if eef_pos is not None else None
|
eef_mat = self._env.robots[0].controller.ee_ori_mat
|
||||||
gripper_qpos = raw_obs.get("robot0_gripper_qpos")
|
gripper_qpos = raw_obs.get("robot0_gripper_qpos")
|
||||||
gripper_qvel = raw_obs.get("robot0_gripper_qvel")
|
gripper_qvel = raw_obs.get("robot0_gripper_qvel")
|
||||||
joint_pos = raw_obs.get("robot0_joint_pos")
|
joint_pos = raw_obs.get("robot0_joint_pos")
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
from lerobot.policies.xvla.processor_xvla import (
|
||||||
|
XVLAAddDomainIdProcessorStep,
|
||||||
|
XVLAImageScaleProcessorStep,
|
||||||
|
XVLARotation6DToAxisAngleProcessorStep,
|
||||||
|
make_xvla_pre_post_processors,
|
||||||
|
)
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import numpy as np
|
||||||
|
import os
|
||||||
|
|
||||||
|
# --- CHANGE THESE TWO PATHS ---
|
||||||
|
dir_a = "/home/jade_choghari/robot/lerobot"
|
||||||
|
dir_b = "/home/jade_choghari/robot/robot2/lerobot"
|
||||||
|
|
||||||
|
# keys = ["input_ids", "image_input", "image_mask", "domain_id", "proprio"]
|
||||||
|
keys = ["domain_id"]
|
||||||
|
|
||||||
|
def load_np(path, key):
|
||||||
|
file_path = os.path.join(path, f"{key}.npy")
|
||||||
|
if not os.path.exists(file_path):
|
||||||
|
raise FileNotFoundError(f"Missing file: {file_path}")
|
||||||
|
return np.load(file_path)
|
||||||
|
|
||||||
|
for k in keys:
|
||||||
|
print(f"\n===== {k} =====")
|
||||||
|
a = load_np(dir_a, k)
|
||||||
|
b = load_np(dir_b, k)
|
||||||
|
print(a)
|
||||||
|
print(b)
|
||||||
|
print("Shapes:", a.shape, b.shape)
|
||||||
|
same_shape = a.shape == b.shape
|
||||||
|
print("Same shape:", same_shape)
|
||||||
|
|
||||||
|
if not same_shape:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Allclose for numeric, array_equal for boolean
|
||||||
|
if a.dtype == bool or b.dtype == bool:
|
||||||
|
equal = np.array_equal(a, b)
|
||||||
|
print("Equal:", equal)
|
||||||
|
|
||||||
|
# For boolean arrays, diff = xor
|
||||||
|
diff = np.sum(a ^ b)
|
||||||
|
print("Num differing elements:", diff)
|
||||||
|
else:
|
||||||
|
close = np.allclose(a, b, atol=1e-6, rtol=1e-6)
|
||||||
|
print("Allclose:", close)
|
||||||
|
|
||||||
|
diff = np.max(np.abs(a - b))
|
||||||
|
print("Max difference:", diff)
|
||||||
@@ -62,6 +62,7 @@ def make_xvla_pre_post_processors(
|
|||||||
padding_side=config.tokenizer_padding_side,
|
padding_side=config.tokenizer_padding_side,
|
||||||
),
|
),
|
||||||
DeviceProcessorStep(device=config.device),
|
DeviceProcessorStep(device=config.device),
|
||||||
|
XVLAAddDomainIdProcessorStep(),
|
||||||
NormalizerProcessorStep(
|
NormalizerProcessorStep(
|
||||||
features=features, norm_map=config.normalization_mapping, stats=dataset_stats
|
features=features, norm_map=config.normalization_mapping, stats=dataset_stats
|
||||||
),
|
),
|
||||||
@@ -276,7 +277,7 @@ class XVLAAddDomainIdProcessorStep(ProcessorStep):
|
|||||||
device: Device to place the domain_id tensor on (default: "cuda")
|
device: Device to place the domain_id tensor on (default: "cuda")
|
||||||
"""
|
"""
|
||||||
|
|
||||||
domain_id: int = 3
|
domain_id: int = 0
|
||||||
device: str = "cuda"
|
device: str = "cuda"
|
||||||
|
|
||||||
def __call__(self, transition: EnvTransition) -> EnvTransition:
|
def __call__(self, transition: EnvTransition) -> EnvTransition:
|
||||||
@@ -387,7 +388,7 @@ def make_xvla_libero_pre_post_processors(
|
|||||||
"""
|
"""
|
||||||
pre_processor_steps: list[ProcessorStep] = []
|
pre_processor_steps: list[ProcessorStep] = []
|
||||||
post_processor_steps: list[ProcessorStep] = []
|
post_processor_steps: list[ProcessorStep] = []
|
||||||
pre_processor_steps.extend([LiberoProcessorStep(), XVLAImageScaleProcessorStep(), XVLAAddDomainIdProcessorStep()])
|
pre_processor_steps.extend([LiberoProcessorStep(), XVLAAddDomainIdProcessorStep()])
|
||||||
post_processor_steps.extend([XVLARotation6DToAxisAngleProcessorStep()])
|
post_processor_steps.extend([XVLARotation6DToAxisAngleProcessorStep()])
|
||||||
return (
|
return (
|
||||||
PolicyProcessorPipeline[dict[str, Any], dict[str, Any]](
|
PolicyProcessorPipeline[dict[str, Any], dict[str, Any]](
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ class _NormalizationMixin:
|
|||||||
return (tensor * std + mean) * 255.0
|
return (tensor * std + mean) * 255.0
|
||||||
|
|
||||||
# Normalize
|
# Normalize
|
||||||
return (tensor / 255.0 - mean) / std
|
return (tensor - mean) / std
|
||||||
|
|
||||||
stats = self._tensor_stats[key]
|
stats = self._tensor_stats[key]
|
||||||
if norm_mode == NormalizationMode.MEAN_STD:
|
if norm_mode == NormalizationMode.MEAN_STD:
|
||||||
|
|||||||
@@ -167,10 +167,8 @@ def rollout(
|
|||||||
# Infer "task" from attributes of environments.
|
# Infer "task" from attributes of environments.
|
||||||
# TODO: works with SyncVectorEnv but not AsyncVectorEnv
|
# TODO: works with SyncVectorEnv but not AsyncVectorEnv
|
||||||
observation = add_envs_task(env, observation)
|
observation = add_envs_task(env, observation)
|
||||||
|
|
||||||
# Apply environment-specific preprocessing (e.g., LiberoProcessorStep for LIBERO)
|
# Apply environment-specific preprocessing (e.g., LiberoProcessorStep for LIBERO)
|
||||||
observation = env_preprocessor(observation)
|
observation = env_preprocessor(observation)
|
||||||
|
|
||||||
observation = preprocessor(observation)
|
observation = preprocessor(observation)
|
||||||
with torch.inference_mode():
|
with torch.inference_mode():
|
||||||
action = policy.select_action(observation)
|
action = policy.select_action(observation)
|
||||||
@@ -178,6 +176,7 @@ def rollout(
|
|||||||
action_transition = {"action": action}
|
action_transition = {"action": action}
|
||||||
action_transition = env_postprocessor(action_transition)
|
action_transition = env_postprocessor(action_transition)
|
||||||
action = action_transition["action"]
|
action = action_transition["action"]
|
||||||
|
|
||||||
# Convert to CPU / numpy.
|
# Convert to CPU / numpy.
|
||||||
action_numpy: np.ndarray = action.to("cpu").numpy()
|
action_numpy: np.ndarray = action.to("cpu").numpy()
|
||||||
assert action_numpy.ndim == 2, "Action dimensions should be (batch, action_dim)"
|
assert action_numpy.ndim == 2, "Action dimensions should be (batch, action_dim)"
|
||||||
|
|||||||
Reference in New Issue
Block a user