Mask Generation
sam2
English
OpenRAL
rskill
segmenter
promptable-segmentation
any
attachment-evidence
grasped-object
Instructions to use OpenRAL/rskill-sam2_1-any-grasped_object_mask-bf16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sam2
How to use OpenRAL/rskill-sam2_1-any-grasped_object_mask-bf16 with sam2:
# Use SAM2 with images import torch from sam2.sam2_image_predictor import SAM2ImagePredictor predictor = SAM2ImagePredictor.from_pretrained("OpenRAL/rskill-sam2_1-any-grasped_object_mask-bf16") with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): predictor.set_image(<your_image>) masks, _, _ = predictor.predict(<input_prompts>)# Use SAM2 with videos import torch from sam2.sam2_video_predictor import SAM2VideoPredictor predictor = SAM2VideoPredictor.from_pretrained("OpenRAL/rskill-sam2_1-any-grasped_object_mask-bf16") with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): state = predictor.init_state(<your_video>) # add new prompts and instantly get the output on the same frame frame_idx, object_ids, masks = predictor.add_new_points(state, <your_prompts>) # propagate the prompts to get masklets throughout the video for frame_idx, object_ids, masks in predictor.propagate_in_video(state): ... - Notebooks
- Google Colab
- Kaggle
chore: publish rSkill OpenRAL/rskill-sam2_1-any-grasped_object_mask-bf16 v0.1.0
Browse files- .gitattributes +1 -0
- SKILL.md +71 -0
- media/front_tablecloth_mask.png +3 -0
- media/wrist_eraser_mask.png +0 -0
- rskill.yaml +104 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
media/front_tablecloth_mask.png filter=lfs diff=lfs merge=lfs -text
|
SKILL.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: rskill-sam2_1-any-grasped_object_mask-bf16
|
| 3 |
+
description: >-
|
| 4 |
+
S1 promptable segmenter. Capabilities: detect on grasped object. SAM 2.1 Hiera-small packaged as a promptable segmenter for grasped-object masking. Answers a geometric point prompt at the tool center point with a binary mask over the current wrist frame, which the HAL's vision attachment-evidence producer intersects with depth to bound the carried payload. One shot per attach / detach / regrasp event, not per frame. Wraps facebook/sam2.1-hiera-small. Emits no actions and drives no actuators. Discovery view of an OpenRAL rSkill — NOT directly runnable by an agent harness; it runs via rSkill.from_pretrained + the robot HAL.
|
| 5 |
+
metadata:
|
| 6 |
+
openral_rskill: true # generated discovery view of an rSkill
|
| 7 |
+
schema_version: 0.1
|
| 8 |
+
rskill_id: OpenRAL/rskill-sam2_1-any-grasped_object_mask-bf16
|
| 9 |
+
manifest: ./rskill.yaml
|
| 10 |
+
role: s1
|
| 11 |
+
kind: segmenter
|
| 12 |
+
embodiment_tags: [any]
|
| 13 |
+
actions: [detect]
|
| 14 |
+
objects: [grasped object]
|
| 15 |
+
scenes: [tabletop, kitchen, indoor, household]
|
| 16 |
+
sensors_required: [rgb]
|
| 17 |
+
runtime: pytorch
|
| 18 |
+
quantization: bf16/pytorch
|
| 19 |
+
min_vram_gb: {bf16: 0.45, fp32: 0.9}
|
| 20 |
+
chunk_size: 1
|
| 21 |
+
latency_budget: {per_chunk_ms: 100.0}
|
| 22 |
+
license_code: Apache-2.0
|
| 23 |
+
license_weights: apache-2.0
|
| 24 |
+
weights_uri: hf://facebook/sam2.1-hiera-small
|
| 25 |
+
source_repo: hf://facebook/sam2.1-hiera-small
|
| 26 |
+
paper_url: https://arxiv.org/abs/2408.00714
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
# rskill-sam2_1-any-grasped_object_mask-bf16 — rSkill discovery view
|
| 30 |
+
|
| 31 |
+
> **Generated view, not a hand-written skill.** This `SKILL.md` is a discovery-only
|
| 32 |
+
> mirror of [`rskill.yaml`](./rskill.yaml), produced by `tools/generate_rskill_skillmd.py`.
|
| 33 |
+
> It lets tools that read the standard agent-skill format find and reason about this
|
| 34 |
+
> OpenRAL rSkill. The `rskill.yaml` manifest is the single source of truth
|
| 35 |
+
> (CLAUDE.md §1.3). Do not edit by hand — edit the manifest and regenerate.
|
| 36 |
+
|
| 37 |
+
## What it is
|
| 38 |
+
|
| 39 |
+
An OpenRAL **promptable segmenter** (`role: s1`, `kind: segmenter`). SAM 2.1 Hiera-small packaged as a promptable segmenter for grasped-object masking. Answers a geometric point prompt at the tool center point with a binary mask over the current wrist frame, which the HAL's vision attachment-evidence producer intersects with depth to bound the carried payload. One shot per attach / detach / regrasp event, not per frame. Wraps facebook/sam2.1-hiera-small. Emits no actions and drives no actuators.
|
| 40 |
+
|
| 41 |
+
## Capabilities
|
| 42 |
+
|
| 43 |
+
- **Verbs:** detect
|
| 44 |
+
- **Objects:** grasped object
|
| 45 |
+
- **Scenes:** tabletop · kitchen · indoor · household
|
| 46 |
+
- **Embodiments:** any
|
| 47 |
+
|
| 48 |
+
## Why this is discovery-only
|
| 49 |
+
|
| 50 |
+
An agent skill is natural-language instructions loaded into an LLM's context. An rSkill
|
| 51 |
+
is an executable artifact: it carries a typed capability/embodiment contract, model weights,
|
| 52 |
+
a runtime, and a license/provenance gate — none of which fit in freeform markdown. So an
|
| 53 |
+
agent can use this view to *select* the right skill, but cannot *execute* it by loading
|
| 54 |
+
this file. Execution always goes through the OpenRAL loader and the robot HAL.
|
| 55 |
+
|
| 56 |
+
## License
|
| 57 |
+
|
| 58 |
+
- **Code:** Apache-2.0.
|
| 59 |
+
- **Weights:** `apache-2.0` — permissive / commercial-use OK
|
| 60 |
+
|
| 61 |
+
## How to actually run it (not via an agent harness)
|
| 62 |
+
|
| 63 |
+
```python
|
| 64 |
+
from openral_rskill import rSkill
|
| 65 |
+
|
| 66 |
+
skill = rSkill.from_pretrained("OpenRAL/rskill-sam2_1-any-grasped_object_mask-bf16")
|
| 67 |
+
# the loader validates embodiment / sensors / runtime / quantization against the target
|
| 68 |
+
# RobotDescription and enforces the weight-license gate before any weights load.
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
See [`rskill.yaml`](./rskill.yaml) for the authoritative, validated manifest.
|
media/front_tablecloth_mask.png
ADDED
|
Git LFS Details
|
media/wrist_eraser_mask.png
ADDED
|
rskill.yaml
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# rSkill manifest — SAM 2.1 (Hiera-small) promptable segmenter (kind: segmenter).
|
| 2 |
+
#
|
| 3 |
+
# The attach-time evidence producer for the attached-object collision stack.
|
| 4 |
+
# The HAL's vision attachment-evidence producer asks this model, one shot per
|
| 5 |
+
# attach / detach / regrasp event, "which pixels of the wrist frame belong to
|
| 6 |
+
# the object in the jaws?" — prompting with a single positive point at the
|
| 7 |
+
# TF-projected TCP. The producer then intersects that mask with the same
|
| 8 |
+
# frame's depth channel and fits the bounded primitives of an
|
| 9 |
+
# AttachedCollisionObject.
|
| 10 |
+
#
|
| 11 |
+
# NOT per-frame. Per-frame carry masking stays geometric containment against
|
| 12 |
+
# the already-fitted attached primitive; this model runs only at the events.
|
| 13 |
+
#
|
| 14 |
+
# Why SAM 2.1 and not SAM 3: SAM 3's headline capability is Promptable *Concept*
|
| 15 |
+
# Segmentation ("segment all instances of this text concept"), which answers a
|
| 16 |
+
# different question than "the one object in these jaws"; its PVS/tracker path
|
| 17 |
+
# does not load cleanly from the public checkpoint under transformers 5.5.4; and
|
| 18 |
+
# its license is a custom, gated Meta "SAM License" whose full text could not be
|
| 19 |
+
# verified. SAM 2.1 is plainly apache-2.0, 22x smaller, and 8x faster.
|
| 20 |
+
|
| 21 |
+
schema_version: "0.1"
|
| 22 |
+
name: "OpenRAL/rskill-sam2_1-any-grasped_object_mask-bf16"
|
| 23 |
+
version: "0.1.0"
|
| 24 |
+
license: "apache-2.0"
|
| 25 |
+
role: "s1"
|
| 26 |
+
kind: "segmenter" # Perception producer; emits masks, no Action
|
| 27 |
+
|
| 28 |
+
# embodiment-agnostic: a perception rSkill needs a wrist camera, not a specific
|
| 29 |
+
# robot. The rSkill<->robot gate exempts these kinds, so the wildcard tag
|
| 30 |
+
# matches any robot/scene.
|
| 31 |
+
embodiment_tags: ["any"] # explicit embodiment-agnostic wildcard
|
| 32 |
+
|
| 33 |
+
# RGB only. The segmenter itself never touches depth — the mask->depth
|
| 34 |
+
# intersection happens on the HAL side, against the same frame's depth channel.
|
| 35 |
+
# The minimums are deliberately low: Sam2Processor resizes every input to 1024x1024
|
| 36 |
+
# internally, so latency was measured FLAT (46-52 ms) from 224px to 1024px. Wrist
|
| 37 |
+
# camera resolution is neither a latency nor a VRAM lever for this model, and a
|
| 38 |
+
# 320x240 SO-101 wrist stream is a first-class input.
|
| 39 |
+
sensors_required:
|
| 40 |
+
- modality: "rgb"
|
| 41 |
+
min_width: 320
|
| 42 |
+
min_height: 240
|
| 43 |
+
|
| 44 |
+
actuators_required: []
|
| 45 |
+
|
| 46 |
+
runtime: "pytorch"
|
| 47 |
+
quantization:
|
| 48 |
+
dtype: "bf16"
|
| 49 |
+
backend: "pytorch"
|
| 50 |
+
# MEASURED on an RTX 4070 Laptop 8 GB (transformers 5.5.4, torch 2.9.1+cu128),
|
| 51 |
+
# 512x512 bf16 input, torch.cuda.max_memory_allocated delta against a pre-load
|
| 52 |
+
# baseline with ~3.5 GiB already resident: 74 MiB of weights, 297 MiB peak
|
| 53 |
+
# allocated, 448 MiB torch-reserved. The fp32 figure below is NOT measured — it
|
| 54 |
+
# is the bf16 peak doubled, a conservative placeholder for the CPU/fp32 path.
|
| 55 |
+
min_vram_gb:
|
| 56 |
+
bf16: 0.45
|
| 57 |
+
fp32: 0.9
|
| 58 |
+
|
| 59 |
+
weights_uri: "hf://facebook/sam2.1-hiera-small"
|
| 60 |
+
|
| 61 |
+
chunk_size: 1
|
| 62 |
+
# MEASURED on the same host: 53 ms warm median, 742 ms first call (weights load
|
| 63 |
+
# + CUDA kernel autotune). The budget is set to 100 ms — the warm figure with
|
| 64 |
+
# ~2x headroom — because that is what has to fit inside the HAL's existing
|
| 65 |
+
# deferred-ack barrier, which already waits ~100 ms for a depth frame. The cold
|
| 66 |
+
# call does NOT fit, which is why the backend must be warm_up()-ed at node
|
| 67 |
+
# activate rather than loaded on demand.
|
| 68 |
+
latency_budget:
|
| 69 |
+
per_chunk_ms: 100.0
|
| 70 |
+
|
| 71 |
+
segmenter:
|
| 72 |
+
engine: "sam2_hf"
|
| 73 |
+
# One positive point at the TF-projected TCP, plus room for negative points at
|
| 74 |
+
# the jaw tips to push the mask off the gripper fingers.
|
| 75 |
+
max_prompt_points: 8
|
| 76 |
+
# SAM 2's three nested hypotheses (subpart / part / whole) are all returned;
|
| 77 |
+
# the HAL producer picks between them on GEOMETRY, never on the model's score.
|
| 78 |
+
multimask: true
|
| 79 |
+
# A handful of pixels cannot bound a payload — drop such masks before they
|
| 80 |
+
# ever reach the depth intersection.
|
| 81 |
+
min_mask_area_px: 64
|
| 82 |
+
|
| 83 |
+
paper_url: "https://arxiv.org/abs/2408.00714"
|
| 84 |
+
source_repo: "hf://facebook/sam2.1-hiera-small"
|
| 85 |
+
|
| 86 |
+
description: >
|
| 87 |
+
SAM 2.1 Hiera-small packaged as a promptable segmenter for grasped-object
|
| 88 |
+
masking. Answers a geometric point prompt at the tool center point with a
|
| 89 |
+
binary mask over the current wrist frame, which the HAL's vision
|
| 90 |
+
attachment-evidence producer intersects with depth to bound the carried
|
| 91 |
+
payload. One shot per attach / detach / regrasp event, not per frame. Wraps
|
| 92 |
+
facebook/sam2.1-hiera-small. Emits no actions and drives no actuators.
|
| 93 |
+
|
| 94 |
+
actions:
|
| 95 |
+
- "detect"
|
| 96 |
+
|
| 97 |
+
objects:
|
| 98 |
+
- "grasped object"
|
| 99 |
+
|
| 100 |
+
scenes:
|
| 101 |
+
- "tabletop"
|
| 102 |
+
- "kitchen"
|
| 103 |
+
- "indoor"
|
| 104 |
+
- "household"
|