segment-anything-model

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

Updated Jul 3, 2026
One-click install
npx skills add https://github.com/CHENHUI-X/toolbox --skill segment-anything-model-chenhui-x
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: segment-anything-model
Source: https://github.com/CHENHUI-X/toolbox/tree/main/custom-skills/models/segment-anything
Command: npx skills add https://github.com/CHENHUI-X/toolbox --skill segment-anything-model-chenhui-x

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 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 SAM checkpoint with sam_model_registry, create a SamPredictor, call set_image on your RGB image, then call predict with point coordinates and labels. Set multimask_output to True to get three candidate masks and pick the one with the highest score.

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

ViT-B is the smallest at 375MB and fastest, ViT-L is medium at 1.2GB, and ViT-H is the largest at 2.4GB with the best accuracy. Use ViT-B when GPU memory or speed is limited, and ViT-H when mask quality matters most.

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 turn those boxes into segmentation masks.

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 run inference in half precision.

Can SAM segment objects in videos?

The original SAM only processes individual images and has no tracking capability. For video segmentation, use SAM 2, which adds a streaming memory architecture to propagate masks across frames from an initial prompt.

Why is SAM missing small objects in automatic mask generation?

The default grid of points may be too sparse for small objects. Increase points_per_side, lower pred_iou_thresh and stability_score_thresh, enable crop_n_layers for multi-scale processing, and reduce min_mask_region_area.