segment-anything-model

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

Updated May 4, 2026
One-click install
npx skills add https://github.com/Junkfooooood/hermes-governance --skill segment-anything-model-junkfooooood
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: segment-anything-model
Source: https://github.com/Junkfooooood/hermes-governance/tree/main/skills/mlops/models/segment-anything
Command: npx skills add https://github.com/Junkfooooood/hermes-governance --skill segment-anything-model-junkfooooood

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 produce high-quality segmentation masks on any image domain without fine-tuning, using simple point, box, or mask prompts. ## Core Features & Use Cases - Interactive Prompt-Based Segmentation: Segment objects with foreground/background points, bounding boxes, or combined prompts, with iterative refinement using previous mask logits. - Automatic Mask Generation: Generate all object masks in an image at once with tunable quality, stability, and density thresholds. - Deployment & Integration: Export to ONNX for browser and edge deployment, or use HuggingFace Transformers with SamModel and SamProcessor. - Use Case: Build an annotation tool where a user clicks on an object in an image and SAM instantly returns a precise mask, accelerating training data creation for downstream vision models. ## Quick Start Load the SAM ViT-H checkpoint with SamPredictor, set an image, and predict a mask from a foreground point prompt at the object's center.

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_coords and point_labels or a bounding box. SAM returns multiple masks with scores; select the highest-scoring one.

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

ViT-B is the smallest and fastest at 375MB, ViT-L is medium at 1.2GB, and ViT-H is the largest and most accurate at 2.4GB. Choose ViT-B for limited GPU memory or speed-critical applications, and ViT-H for best mask quality.

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-driven segmentation.

Can SAM run on CPU or in the browser?

SAM can run on CPU but inference is slow, especially for the image encoder. For browser and edge deployment, export the mask decoder to ONNX with the export script and compute image embeddings separately.

Why does SAM run out of CUDA memory?

The ViT-H model requires significant GPU memory, especially with large images. Switch to the ViT-B checkpoint, resize images to a maximum dimension, use half precision, and call torch.cuda.empty_cache() between batches.

When should I not use SAM for segmentation?

SAM produces class-agnostic masks, so use YOLO or Detectron2 for real-time detection with class labels, Mask2Former for semantic or panoptic segmentation with categories, and SAM 2 for video segmentation with object tracking.