segmentation-sam2

Generates pixel-level object masks from point and box prompts using Segment Anything 2.

3.0k|478|Updated Mar 5, 2019
One-click install
npx skills add https://github.com/SharpAI/DeepCamera --skill segmentation-sam2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: segmentation-sam2
Source: https://github.com/SharpAI/DeepCamera/tree/main/skills/segmentation/sam2-segmentation
Command: npx skills add https://github.com/SharpAI/DeepCamera --skill segmentation-sam2

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires segment-anything-2, torch, torchvision, numpy, opencv-python-headless, Pillow, and includes scripts (resource) components.

What problem does it solve?

Manually drawing object masks for video annotation is slow and labor-intensive. This Skill lets you click on any object in a video frame and instantly receive a precise segmentation mask, dramatically accelerating dataset labeling and annotation workflows.

Core Features & Use Cases

  • Click-to-Segment: Send point or bounding-box prompts over a JSON-lines stdin/stdout protocol and receive masks with confidence scores and bounding boxes.
  • Video Tracking: Segment an object in one frame and propagate the mask across subsequent frames in a clip.
  • Hardware-Aware Setup: The deploy script auto-detects CUDA, Apple Silicon MPS, or CPU and installs the matching PyTorch build and SAM2 checkpoint.
  • Use Case: In an annotation studio, a user clicks a person in a surveillance frame; the Skill returns a pixel mask and bounding box that can be saved as a labeled training sample for a detection model.

Quick Start

Run the deploy script to install dependencies and the model, then ask the assistant to segment the person in the current video frame using a click point.

Frequently Asked Questions about segmentation-sam2

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I segment objects in a video frame with SAM2?

Send an encode command with the frame path, then a segment command containing point coordinates with labels or a bounding box over stdin as JSON lines. The Skill returns a mask file path, base64 mask, confidence score, and bounding box.

What is Segment Anything 2 used for in annotation workflows?

Segment Anything 2 converts user clicks or boxes into pixel-level object masks, replacing manual polygon drawing. It is used to label datasets, create training samples, and track objects across video frames.

Does SAM2 segmentation run on Apple Silicon or CPU?

Yes, the deploy script detects Apple Silicon and installs PyTorch with MPS support, and falls back to a CPU-only PyTorch build when no GPU is present. NVIDIA GPUs use the CUDA build automatically.

Which SAM2 model sizes are available and how do I choose?

Four checkpoints are supported: sam2-tiny, sam2-small, sam2-base, and sam2-large, selectable via the model parameter. Smaller models run faster on CPU or MPS, while larger models give higher mask quality on CUDA GPUs.

Why does the segment command return a no image encoded error?

The predictor requires an encoded frame before prompting. Send an encode command with a valid frame_path first; the segment command fails with an error if no image has been loaded into the predictor.