Instructions to use AlexWortega/tinyvla with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LeRobot
How to use AlexWortega/tinyvla with LeRobot:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Upload tinyvla2/src/tinyvla/data/eval_utils.py with huggingface_hub
Browse files
tinyvla2/src/tinyvla/data/eval_utils.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Shared observation adapter for offline evaluation.
|
| 2 |
+
|
| 3 |
+
Every eval script must feed the policy exactly what training fed it. Training
|
| 4 |
+
(see mixture.CanonicalSource.__getitem__) normalizes observation.state with the
|
| 5 |
+
dataset's own mean/std and then zero-pads to max_state_dim. Early eval scripts
|
| 6 |
+
passed the RAW state truncated to 6 dims, which is out of distribution by orders
|
| 7 |
+
of magnitude for joint-angle datasets and silently drops mobile-base channels.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
from __future__ import annotations
|
| 11 |
+
|
| 12 |
+
import torch
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class StateAdapter:
|
| 16 |
+
"""Per-dataset state normalizer matching the training pipeline."""
|
| 17 |
+
|
| 18 |
+
def __init__(self, ds_meta, max_state_dim: int):
|
| 19 |
+
s = ds_meta.stats.get("observation.state")
|
| 20 |
+
self.max_state_dim = max_state_dim
|
| 21 |
+
self.mean = torch.as_tensor(s["mean"], dtype=torch.float32) if s else None
|
| 22 |
+
self.std = torch.as_tensor(s["std"], dtype=torch.float32).clamp(min=1e-6) if s else None
|
| 23 |
+
|
| 24 |
+
def __call__(self, state: torch.Tensor) -> torch.Tensor:
|
| 25 |
+
x = state.float()
|
| 26 |
+
if self.mean is not None:
|
| 27 |
+
n = min(len(x), len(self.mean))
|
| 28 |
+
x = torch.cat([(x[:n] - self.mean[:n]) / self.std[:n], x[n:]])
|
| 29 |
+
x = x[: self.max_state_dim]
|
| 30 |
+
return torch.nn.functional.pad(x, (0, max(0, self.max_state_dim - len(x))))
|