mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-25 02:36:11 +00:00
vla-jepa relative actions
This commit is contained in:
@@ -56,6 +56,14 @@ class VLAJEPAConfig(PreTrainedConfig):
|
|||||||
action_dim: int = 7
|
action_dim: int = 7
|
||||||
state_dim: int = 8
|
state_dim: int = 8
|
||||||
|
|
||||||
|
# Relative actions: converts absolute actions to relative (action -= state) during
|
||||||
|
# preprocessing, and reverses it at postprocessing. Requires `state_dim` (OBS_STATE).
|
||||||
|
use_relative_actions: bool = False
|
||||||
|
# Joint names to keep absolute (not converted to relative). Empty list = all dims relative.
|
||||||
|
relative_exclude_joints: list[str] = field(default_factory=lambda: ["gripper"])
|
||||||
|
# Populated at runtime from dataset metadata by make_policy (used to build the exclude mask).
|
||||||
|
action_feature_names: list[str] | None = None
|
||||||
|
|
||||||
num_action_tokens_per_timestep: int = 8
|
num_action_tokens_per_timestep: int = 8
|
||||||
num_embodied_action_tokens_per_instruction: int = 32
|
num_embodied_action_tokens_per_instruction: int = 32
|
||||||
num_inference_timesteps: int = 4
|
num_inference_timesteps: int = 4
|
||||||
|
|||||||
@@ -20,11 +20,13 @@ import torch
|
|||||||
|
|
||||||
from lerobot.policies.vla_jepa.configuration_vla_jepa import VLAJEPAConfig
|
from lerobot.policies.vla_jepa.configuration_vla_jepa import VLAJEPAConfig
|
||||||
from lerobot.processor import (
|
from lerobot.processor import (
|
||||||
|
AbsoluteActionsProcessorStep,
|
||||||
EnvTransition,
|
EnvTransition,
|
||||||
PolicyAction,
|
PolicyAction,
|
||||||
PolicyProcessorPipeline,
|
PolicyProcessorPipeline,
|
||||||
ProcessorStep,
|
ProcessorStep,
|
||||||
ProcessorStepRegistry,
|
ProcessorStepRegistry,
|
||||||
|
RelativeActionsProcessorStep,
|
||||||
TransitionKey,
|
TransitionKey,
|
||||||
UnnormalizerProcessorStep,
|
UnnormalizerProcessorStep,
|
||||||
make_default_policy_processor_steps,
|
make_default_policy_processor_steps,
|
||||||
@@ -109,10 +111,21 @@ def make_vla_jepa_pre_post_processors(
|
|||||||
]:
|
]:
|
||||||
features = {**config.input_features, **config.output_features}
|
features = {**config.input_features, **config.output_features}
|
||||||
steps = make_default_policy_processor_steps(config, dataset_stats)
|
steps = make_default_policy_processor_steps(config, dataset_stats)
|
||||||
|
|
||||||
|
# Shared relative-action step (OpenPI order: raw -> relative -> normalize -> model ->
|
||||||
|
# unnormalize -> absolute). The SAME instance is passed to AbsoluteActionsProcessorStep
|
||||||
|
# below so its cached raw state (set during preprocessing) flows to postprocessing.
|
||||||
|
relative_step = RelativeActionsProcessorStep(
|
||||||
|
enabled=config.use_relative_actions,
|
||||||
|
exclude_joints=getattr(config, "relative_exclude_joints", []),
|
||||||
|
action_names=getattr(config, "action_feature_names", None),
|
||||||
|
)
|
||||||
|
|
||||||
input_steps = [
|
input_steps = [
|
||||||
steps.rename_observations,
|
steps.rename_observations,
|
||||||
steps.add_batch_dim,
|
steps.add_batch_dim,
|
||||||
steps.to_device,
|
steps.to_device,
|
||||||
|
relative_step,
|
||||||
steps.normalize,
|
steps.normalize,
|
||||||
]
|
]
|
||||||
output_steps: list[ProcessorStep] = []
|
output_steps: list[ProcessorStep] = []
|
||||||
@@ -131,6 +144,11 @@ def make_vla_jepa_pre_post_processors(
|
|||||||
stats=dataset_stats,
|
stats=dataset_stats,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
# Reverse the relative conversion on the unnormalized action, before gripper binarization.
|
||||||
|
# gripper is kept absolute by relative_exclude_joints, so the two steps touch disjoint dims.
|
||||||
|
output_steps.append(
|
||||||
|
AbsoluteActionsProcessorStep(enabled=config.use_relative_actions, relative_step=relative_step)
|
||||||
|
)
|
||||||
if config.binarize_gripper_action:
|
if config.binarize_gripper_action:
|
||||||
output_steps.append(
|
output_steps.append(
|
||||||
BinarizeGripperProcessorStep(gripper_dim=config.gripper_dim, threshold=config.gripper_threshold)
|
BinarizeGripperProcessorStep(gripper_dim=config.gripper_dim, threshold=config.gripper_threshold)
|
||||||
|
|||||||
Reference in New Issue
Block a user