segment-anything-model

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

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

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 point clicks, bounding boxes, or combined prompts with iterative refinement using SamPredictor. - Automatic Mask Generation: Produce all object masks in an image at once with SamAutomaticMaskGenerator, with tunable quality and density thresholds. - Deployment & Integration: Export to ONNX for edge deployment, build FastAPI/Gradio services, or combine with GroundingDINO for text-prompted segmentation. - Use Case: Build an annotation tool where users click on objects to instantly generate high-quality masks, then export the results as a labeled dataset for training downstream vision models. ## Quick Start Ask the AI to segment an object in your image by providing a point or bounding box prompt using the Segment Anything Model.

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 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 at 375MB and fastest, ViT-H is the largest at 2.4GB with the best accuracy, and ViT-L sits in between at 1.2GB. Use ViT-B for limited GPU memory or speed-critical applications.

Can SAM do text-prompted segmentation?

SAM alone only accepts point, box, and mask prompts, not text. Combine it with GroundingDINO, which converts text descriptions into bounding boxes that SAM then turns into masks.

Does SAM work on medical or grayscale images?

Yes, SAM works zero-shot on domain-specific images, but grayscale inputs must be converted to three-channel RGB first. For better medical results, consider MedSAM, a SAM variant fine-tuned on medical imaging data.

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, call torch.cuda.empty_cache() between images, or use half precision.

When should I use SAM instead of YOLO or Mask2Former?

Use SAM when you need class-agnostic masks without training, such as annotation tools or novel domains. Choose YOLO or Detectron2 for real-time detection with class labels, and Mask2Former for semantic or panoptic segmentation with categories.