segment-anything-model

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

Updated Jun 5, 2026
One-click install
npx skills add https://github.com/xu1713/openhorse --skill segment-anything-model-xu1713
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: segment-anything-model
Source: https://github.com/xu1713/openhorse/tree/main/openhorse/openhorse/skills/mlops/models/segment-anything
Command: npx skills add https://github.com/xu1713/openhorse --skill segment-anything-model-xu1713

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 guidance for using Meta's Segment Anything Model (SAM) to segment any object in any image 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. - Automatic Mask Generation: Produce all object masks in an image at once with configurable quality, stability, and density thresholds. - Deployment & Integration: Export to ONNX for edge deployment, use HuggingFace Transformers, or build FastAPI/Gradio annotation services. - Use Case: Build an annotation tool where a user clicks on an object in an image and instantly receives a high-quality segmentation mask to generate training data for a downstream vision model. ## Quick Start Use the segment-anything skill to segment the object at a clicked point in my image and return the best mask with its quality score.

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 SAM checkpoint with sam_model_registry, create a SamPredictor, call set_image on your RGB image, then predict with point coordinates and labels or a bounding box. The predictor returns masks with quality 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) and slowest but most accurate. Use ViT-B when GPU memory or speed is limited.

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 without a GPU?

SAM can run on CPU by loading the model without calling .to("cuda"), but inference is significantly slower, especially for ViT-H. For limited GPU memory, use the ViT-B checkpoint, half precision, or export to ONNX for lighter deployment.

Why does SAM run out of CUDA memory?

CUDA out of memory occurs because ViT-H requires substantial VRAM, especially with large images or batch processing. Switch to the ViT-B model, resize images, call torch.cuda.empty_cache() between images, or process on CPU.

When should I not use SAM for segmentation?

Avoid SAM when you need class labels, since it produces class-agnostic masks. Use YOLO or Detectron2 for real-time object detection with categories, Mask2Former for semantic segmentation, and SAM 2 for video segmentation tasks.