Instructions to use Lyndow/ExoWrist_Smolvla with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Piper
How to use Lyndow/ExoWrist_Smolvla with Piper:
# 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
Download code/intent_rack_demo/src/models/intent_model.py from Lyndow/ExoWrist_Smolvla: direct link, hf CLI and curl.
- Browser
- Download file 2.16 kB
-
https://huggingface.co/Lyndow/ExoWrist_Smolvla/resolve/main/code/intent_rack_demo/src/models/intent_model.py
- Command line
-
hf download hf://Lyndow/ExoWrist_Smolvla/code/intent_rack_demo/src/models/intent_model.py
-
curl -L -o intent_model.py https://huggingface.co/Lyndow/ExoWrist_Smolvla/resolve/main/code/intent_rack_demo/src/models/intent_model.py
2.16 kB
| """Small temporal intent model operating on frozen two-view embeddings.""" | |
| from __future__ import annotations | |
| import torch | |
| from torch import nn | |
| class TwoViewIntentGRU(nn.Module): | |
| """Fuse Top/Front embeddings at each time and predict two binary states.""" | |
| def __init__( | |
| self, | |
| embedding_dim: int, | |
| projection_dim: int = 384, | |
| hidden_dim: int = 256, | |
| num_layers: int = 1, | |
| dropout: float = 0.15, | |
| ) -> None: | |
| super().__init__() | |
| self.embedding_dim = embedding_dim | |
| self.projection_dim = projection_dim | |
| self.hidden_dim = hidden_dim | |
| self.num_layers = num_layers | |
| self.projection = nn.Sequential( | |
| nn.Linear(embedding_dim * 2, projection_dim), | |
| nn.LayerNorm(projection_dim), | |
| nn.GELU(), | |
| nn.Dropout(dropout), | |
| ) | |
| self.temporal = nn.GRU( | |
| input_size=projection_dim, | |
| hidden_size=hidden_dim, | |
| num_layers=num_layers, | |
| batch_first=True, | |
| dropout=dropout if num_layers > 1 else 0.0, | |
| ) | |
| self.heads = nn.Linear(hidden_dim, 2) | |
| def forward(self, embeddings: torch.Tensor) -> torch.Tensor: | |
| if embeddings.ndim != 4 or embeddings.shape[2] != 2: | |
| raise ValueError( | |
| "expected embeddings shaped [batch, time, 2 views, feature], " | |
| f"got {tuple(embeddings.shape)}" | |
| ) | |
| batch, steps, views, features = embeddings.shape | |
| if features != self.embedding_dim: | |
| raise ValueError(f"expected feature dim {self.embedding_dim}, got {features}") | |
| fused = embeddings.reshape(batch, steps, views * features) | |
| projected = self.projection(fused) | |
| sequence, _ = self.temporal(projected) | |
| return self.heads(sequence[:, -1]) | |
| def model_config(model: TwoViewIntentGRU) -> dict[str, int | float]: | |
| dropout = model.projection[-1].p | |
| return { | |
| "embedding_dim": model.embedding_dim, | |
| "projection_dim": model.projection_dim, | |
| "hidden_dim": model.hidden_dim, | |
| "num_layers": model.num_layers, | |
| "dropout": dropout, | |
| } | |