Segment Anything Model: Promptable image segmentation
Transformer-based promptable segmentation with zero-shot generalization.
Learn more about Segment Anything
Segment Anything Model (SAM) is a vision foundation model designed for promptable segmentation tasks. It uses a transformer-based architecture with an image encoder, prompt encoder, and mask decoder to process visual input and generate segmentation masks. The model was trained on 11 million images with 1.1 billion masks, enabling zero-shot performance across diverse segmentation tasks and visual domains. It supports multiple prompt types including points, boxes, and text, and can operate in both interactive mode with user prompts or automatic mode to segment all objects in an image.
Large-scale training dataset
Trained on 11 million images and 1.1 billion masks, providing broad coverage across visual domains and enabling zero-shot generalization to new segmentation tasks without task-specific fine-tuning.
Flexible prompt interface
Accepts multiple input prompt types including points, bounding boxes, and masks, allowing both interactive segmentation guided by user input and fully automatic mask generation for entire images.
ONNX export capability
The lightweight mask decoder can be exported to ONNX format for deployment across different runtime environments, including browser-based applications, without requiring the full model infrastructure.
from segment_anything import SamPredictor, sam_model_registry
import numpy as np
import cv2
image = cv2.imread("image.jpg")
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
sam = sam_model_registry["vit_h"](checkpoint="sam_vit_h.pth")
predictor = SamPredictor(sam)
predictor.set_image(image)
input_point = np.array([[500, 375]])
input_label = np.array([1])
masks, scores, logits = predictor.predict(point_coords=input_point, point_labels=input_label)See how people are using Segment Anything
Top in AI & ML
Related Repositories
Discover similar tools and frameworks used by developers
Context7
MCP server delivering version-specific library documentation to LLMs.
Claude Code
Local CLI integrating Claude AI into development workflows.
PaddleOCR
Multilingual OCR toolkit with document structure extraction.
FAISS
Efficient approximate nearest neighbor search for billion-scale vectors.
Awesome Nano Banana
Curated collection of images and prompts from Google's Gemini-2.5-Flash-Image model with model comparisons.
Related Reading
Guides and comparisons from the Greptile content library
What is a pull request & why is it important for code reviews?
Pull requests protect your codebase, but traditional PR workflows are becoming the bottleneck as AI writes more code. Learn what pull requests are, how to create one, and how to automate PR review so velocity and trust scale together.
Best Code Review Tools in 2026
The best code review tools in 2026, compared on pricing, features, deployment options, and ideal use cases for teams of any size.
Best Developer Productivity Tools in 2026
The best developer productivity tools in 2026, compared by the workflow problem they solve: code review, autocomplete, AI-native editing, terminal agents, code search, observability, and security.
Guide to Self-Hosted AI Code Review for GitLab and GitHub Enterprise [2026]
How self-hosted AI code review works on GitLab Self-Managed and GitHub Enterprise Server, how it compares to SaaS review tools, what to look for in a self-hosted tool, and what a self-hosted rollout actually takes.