segment-anything-model

Generate zero-shot image segmentation masks from point, box, and mask prompts using SAM.

Updated Jul 10, 2026
One-click install
npx skills add https://github.com/AvaTar-ArTs/.Agent-skills --skill segment-anything-model-avatar-arts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: segment-anything-model
Source: https://github.com/AvaTar-ArTs/.Agent-skills/tree/main/skills/mlops/models/segment-anything
Command: npx skills add https://github.com/AvaTar-ArTs/.Agent-skills --skill segment-anything-model-avatar-arts

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires segment-anything, transformers, torch, and includes references (resource) components.

What problem does it solve? Segmenting objects in images traditionally requires training task-specific models on labeled datasets. This Skill provides operational guidance for Meta's Segment Anything Model (SAM), which produces object masks on any image domain without fine-tuning, using simple point, box, or mask prompts. ## Core Features & Use Cases - Interactive Segmentation: Generate masks from foreground/background points, bounding boxes, or combined prompts with iterative refinement using previous mask logits. - Automatic Mask Generation: Produce all object masks in an image at once with tunable quality, stability, and density thresholds via SamAutomaticMaskGenerator. - Deployment & Integration: Export to ONNX for browser and edge deployment, or use HuggingFace Transformers (SamModel/SamProcessor) for pipeline integration. - Use Case: Build an annotation tool where a user clicks an object in an image and SAM returns a pixel-accurate mask, which is then exported in COCO RLE format to create training data for a downstream detection model. ## Quick Start Use the segment-anything skill to segment the object at a clicked point in my image and return the highest-scoring mask.

Frequently Asked Questions about segment-anything-model

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

FAQPage Schema
How do I segment an object in an image with SAM?

Load a checkpoint with sam_model_registry, create a SamPredictor, call set_image once, then predict with point coordinates and labels (1 for foreground, 0 for background). The predictor returns masks with scores; select the highest-scoring mask.

What is the difference between SAM ViT-B, ViT-L, and ViT-H?

ViT-B is the smallest (375MB) and fastest with good accuracy, ViT-L is medium (1.2GB), and ViT-H is the largest (2.4GB) with the best accuracy but slowest inference. Choose based on your GPU memory and speed requirements.

SAM vs GroundingDINO for text-prompted segmentation?

SAM alone does not accept text prompts; it only takes points, boxes, or masks. Combine GroundingDINO, which converts text descriptions into bounding boxes, with SAM to generate masks from those boxes for text-prompted segmentation.

Can SAM run on CPU or only GPU?

SAM can run on CPU by not calling .to("cuda"), but inference is significantly slower, especially for the image encoder. For limited GPU memory, use the ViT-B model, half precision, or export to ONNX for optimized runtime.

Why does SAM return empty or incorrect masks?

Incorrect masks usually result from wrong coordinate order (points must be x,y not row,col), BGR instead of RGB images, or ambiguous prompts. Add background points, use a bounding box, or combine box and point prompts to improve results.

When should I not use SAM for segmentation?

Avoid SAM when you need class labels with real-time detection (use YOLO or Detectron2), semantic or panoptic segmentation with categories (use Mask2Former), or video tracking (use SAM 2, which adds streaming memory across frames).