mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-22 12:09:42 +00:00
chore(processors): tokenizers raises and remove tensor conversion (#1949)
This commit is contained in:
@@ -209,7 +209,7 @@ class _NormalizationMixin:
|
|||||||
new_observation[key] = self._apply_transform(tensor, key, feature.type, inverse=inverse)
|
new_observation[key] = self._apply_transform(tensor, key, feature.type, inverse=inverse)
|
||||||
return new_observation
|
return new_observation
|
||||||
|
|
||||||
def _normalize_action(self, action: Any, inverse: bool) -> Tensor:
|
def _normalize_action(self, action: Tensor, inverse: bool) -> Tensor:
|
||||||
# Convert to tensor but preserve original dtype for adaptation logic
|
# Convert to tensor but preserve original dtype for adaptation logic
|
||||||
"""
|
"""
|
||||||
Applies (un)normalization to an action tensor.
|
Applies (un)normalization to an action tensor.
|
||||||
@@ -221,8 +221,7 @@ class _NormalizationMixin:
|
|||||||
Returns:
|
Returns:
|
||||||
The transformed action tensor.
|
The transformed action tensor.
|
||||||
"""
|
"""
|
||||||
tensor = torch.as_tensor(action)
|
processed_action = self._apply_transform(action, "action", FeatureType.ACTION, inverse=inverse)
|
||||||
processed_action = self._apply_transform(tensor, "action", FeatureType.ACTION, inverse=inverse)
|
|
||||||
return processed_action
|
return processed_action
|
||||||
|
|
||||||
def _apply_transform(
|
def _apply_transform(
|
||||||
|
|||||||
@@ -118,14 +118,11 @@ class TokenizerProcessorStep(ObservationProcessorStep):
|
|||||||
"""
|
"""
|
||||||
complementary_data = transition.get(TransitionKey.COMPLEMENTARY_DATA)
|
complementary_data = transition.get(TransitionKey.COMPLEMENTARY_DATA)
|
||||||
if complementary_data is None:
|
if complementary_data is None:
|
||||||
return None
|
raise ValueError("Complementary data is None so no task can be extracted from it")
|
||||||
|
|
||||||
if self.task_key not in complementary_data:
|
|
||||||
return None
|
|
||||||
|
|
||||||
task = complementary_data[self.task_key]
|
task = complementary_data[self.task_key]
|
||||||
if task is None:
|
if task is None:
|
||||||
return None
|
raise ValueError("Task extracted from Complementary data is None")
|
||||||
|
|
||||||
# Standardize to a list of strings for the tokenizer
|
# Standardize to a list of strings for the tokenizer
|
||||||
if isinstance(task, str):
|
if isinstance(task, str):
|
||||||
@@ -150,7 +147,7 @@ class TokenizerProcessorStep(ObservationProcessorStep):
|
|||||||
"""
|
"""
|
||||||
task = self.get_task(self.transition)
|
task = self.get_task(self.transition)
|
||||||
if task is None:
|
if task is None:
|
||||||
return observation
|
raise ValueError("Task cannot be None")
|
||||||
|
|
||||||
# Tokenize the task (this will create CPU tensors)
|
# Tokenize the task (this will create CPU tensors)
|
||||||
tokenized_prompt = self._tokenize_text(task)
|
tokenized_prompt = self._tokenize_text(task)
|
||||||
|
|||||||
Reference in New Issue
Block a user