SAM ViT-Base
SAMFeaturedApache 2.0vision

SAM ViT-Base

Updated Nov 16, 2026
Parameters
90M
Context
8,192
License
Apache 2.0
Updated
Nov 16, 2026

Will it run on your hardware?

Pick your GPU memory - see which quantizations fit, and the cheapest card for the rest

Runs on your 24 GB - best at Q4_K_M
1 of 1 quantizations fit SAM ViT-Base with real runtime overhead.
Q4_K_M
0.1 GB
fits tight too big

Need an exact figure for your context length? Use the VRAM calculator.

Run it locally

Copy-paste - running in under a minute

vLLMOpenAI-compatible API
vllm serve facebook/sam-vit-base

New to this? Start with Ollama · serve to many users with vLLM.

Deep dive

Notes, sources, and the full write-up

SAM - Segment Anything ModelLink to this section

SAM (Segment Anything Model) by Meta AI is a breakthrough in computer vision. Given an image and a prompt (point, box, or automatically generated grid), it produces high-quality segmentation masks for any object. Trained on 11M images and 1.1B masks - the largest segmentation dataset ever.

How it worksLink to this section

SAM has three components:

  1. VisionEncoder (ViT) - computes image embeddings
  2. PromptEncoder - embeds points, boxes, or masks
  3. MaskDecoder - lightweight transformer predicting masks

UsageLink to this section

from transformers import pipeline
 
generator = pipeline("mask-generation", device=0)
 
# Automatically segment everything in an image
outputs = generator("https://example.com/image.jpg")
 
# Or prompt with a point
outputs = generator("image.jpg", points=[[450, 600]])

Three model sizesLink to this section

VariantParamsSpeed
ViT-Base93.7MFast
ViT-Large307MBalanced
ViT-Huge641MMost accurate

When to useLink to this section

  • Photo editing - select and remove objects
  • Medical imaging - segment organs/tumors
  • Robotics - object grasping
  • Creative tools - background removal
  • Video editing - object tracking across frames

From the community

What users are saying

“Hi @abdullahalrafib Thanks for the issue! Can you try on a more recent version of transformers ? pip install -U transformers The script below: Worked fine on my end, you could either pass a list of PIL images or a list of image URLs”

“It seems, that this model contains one more parameter, then the original model from https://github.com/facebookresearch/segment-anything. Why so and if it is normal, can you please provide a conversion script?”

“I am using this code, this part runs ok after I try to generate the outputs with: and get this error:”

Frequently asked

Quick answers to common questions

How much VRAM does SAM ViT-Base need?

SAM ViT-Base with 90M parameters needs significant VRAM depending on quantization. Use our VRAM calculator for an exact estimate.

Is SAM ViT-Base better than other SAM models?

SAM ViT-Base has 90M parameters with 8,192 context - a strong choice for image-segmentation.

What license is SAM ViT-Base under?

SAM ViT-Base is released under the Apache 2.0 license, making it suitable for most commercial and personal projects.

What hardware runs SAM ViT-Base well?

With 90M parameters, SAM ViT-Base is small enough for most consumer GPUs, Apple Silicon Macs, and many CPUs. Check our hardware directory for specific recommendations.

What is the best quantization for SAM ViT-Base?

Q4_K_M is the recommended sweet spot - ~98% of FP16 quality at ~27% of the size. Step up to Q5_K_M or Q8_0 only if you have spare VRAM. Use our VRAM calculator to compare.

What models compete with SAM ViT-Base?

SAM ViT-Base competes with other models in its class. Browse our model directory for comparisons, benchmarks, and community reviews to find the best fit.

Compare & pair with

Similar models and recommended hardware

Related models

Recommended hardware

Nearby options

Similar models and compatible hardware by spec