segment-anything-model

Generates zero-shot image segmentation masks from point, box, or automatic prompts using SAM.

1|Updated Mar 5, 2026
One-click install
npx skills add https://github.com/Clay-HHK/claude-skills --skill segment-anything-model-clay-hhk
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: segment-anything-model
Source: https://github.com/Clay-HHK/claude-skills/tree/main/segment-anything
Command: npx skills add https://github.com/Clay-HHK/claude-skills --skill segment-anything-model-clay-hhk

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Segmenting objects in images traditionally requires task-specific training data and model fine-tuning. This Skill provides guidance for using Meta's Segment Anything Model (SAM) to segment any object in any image domain with zero-shot transfer, using simple point, box, or mask prompts. ## Core Features & Use Cases - Interactive Segmentation: Segment objects with point clicks, bounding boxes, or combined prompts, with iterative refinement using previous mask outputs. - Automatic Mask Generation: Produce 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 returns a high-quality binary mask with an IoU confidence score, ready to export as COCO RLE annotations for training downstream vision models. ## Quick Start Use the segment-anything skill to segment the object at point (500, 375) 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 checkpoint with sam_model_registry, create a SamPredictor, call set_image once, then predict with point coordinates and labels or a bounding box. The predictor returns masks, IoU scores, and logits; select the mask with the highest score.

How to generate all object masks in an image automatically?▼

Use SamAutomaticMaskGenerator with your SAM model and call generate on the image. Tune points_per_side, pred_iou_thresh, and stability_score_thresh to control mask density and quality, and filter results by predicted_iou or area.

SAM vs GroundingDINO for text-prompted segmentation?▼

SAM alone does not accept text prompts; it only takes points, boxes, or masks. Combine GroundingDINO for text-to-box detection with SAM for box-to-mask segmentation when you need language-driven segmentation.

Does SAM work with HuggingFace Transformers?▼

Yes, transformers 4.30+ includes SamModel and SamProcessor with pretrained checkpoints like facebook/sam-vit-huge. Pass images and input_points to the processor, run the model, then post-process masks back to original image size.

Why does SAM run out of CUDA memory?▼

The ViT-H checkpoint requires significant VRAM, especially with large images. Switch to the ViT-B model (375MB), resize images, use half precision with sam.half(), or call torch.cuda.empty_cache() between batches.

When should I not use Segment Anything?▼

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