Meta SAM 3 Open-Vocabulary Segmentation: Gated Token Mirror Downloads & Practical Inference
Download gated facebook/sam3 fast via HF-Mirror with a Read Token, skip duplicate .pt checkpoints, and run text-prompted concept segmentation cleanly in BF16.
ποΈ 1. What SAM 3 Actually Simplifies Compared to SAM 2
Anyone who built industrial inspection or auto-labeling pipelines on SAM 2 hit the same ceiling quickly: SAM 2 tracks masks cleanly, but it has no concept of semantics. To segment every "safety helmet" or "scratched solder joint" in a warehouse feed, you had to bolt Grounding DINO or YOLO in front of SAM 2, juggling two separate checkpoints, two preprocessing loops, and double the VRAM.
facebook/sam3 (7,500+ likes and 1.6M+ monthly downloads on Hugging Face) collapses that two-stage stack into one model. Alongside classic point and box prompts, SAM 3 natively supports Promptable Concept Segmentationβhand it a short noun phrase or a visual exemplar box and it locates, segments, and tracks every matching instance across images or video frames.
π 2. Fixing 401/403 Errors on Gated facebook/sam3 & Skipping Duplicate Weights
Unlike Apache-licensed weights, facebook/sam3 enforces gated=manual access control. Pointing HF_ENDPOINT at a mirror alone will still fail with 401 Unauthorized or 403 Forbidden until your account clears three steps:
- Sign into Hugging Face, open
facebook/sam3, submit the SAM license request form, and wait until the page shows Granted; - Create a dedicated Read-only access token (
hf_...) under your account token settingsβnever put Write tokens into training containers; - Export both
HF_ENDPOINT="https://hf-mirror.net"andHF_TOKEN. HF-Mirror forwards the TLSAuthorizationheader transparently to Hugging Face's auth backend without storing or logging credentials.
export HF_ENDPOINT="https://hf-mirror.net"
export HF_TOKEN="hf_your_read_only_token"
#
# The repo bundles BOTH model.safetensors AND sam3.pt!
# Exclude sam3.pt when using Hugging Face transformers to cut download size in half
huggingface-cli download facebook/sam3 \
--exclude "sam3.pt" \
--local-dir /data/models/sam3 \
--local-dir-use-symlinks False \
--resume-download
That --exclude "sam3.pt" flag is worth remembering: Meta ships both model.safetensors (for transformers) and sam3.pt (for native PyTorch scripts) side by side. Filtering out the format you don't use cuts transfer time and disk footprint right in half.
π§© 3. Text-Prompted Inference & Keeping Video VRAM Flat
Once weights sit on disk, make sure your transformers install includes Sam3Model and load strictly with local_files_only=True so production workers never stall on token re-checks:
import torch
from PIL import Image
from transformers import Sam3Model, Sam3Processor
#
model_dir = "/data/models/sam3"
device = "cuda" if torch.cuda.is_available() else "cpu"
#
processor = Sam3Processor.from_pretrained(model_dir, local_files_only=True)
model = Sam3Model.from_pretrained(
model_dir,
torch_dtype=torch.bfloat16,
local_files_only=True
).to(device).eval()
#
image = Image.open("warehouse_frame.jpg").convert("RGB")
inputs = processor(images=image, text="safety helmet", return_tensors="pt").to(device)
#
with torch.inference_mode(), torch.autocast(device_type="cuda", dtype=torch.bfloat16):
outputs = model(**inputs)
#
results = processor.post_process_instance_segmentation(
outputs,
threshold=0.5,
mask_threshold=0.5,
target_sizes=inputs.get("original_sizes").tolist()
)[0]
print(f"Detected instances: {len(results['masks'])}, scores: {results['scores'].tolist()}")
Field Notes From Real Workloads
- Short noun phrases beat sentences: The text encoder responds noticeably better to concise labels (
"yellow forklift","cracked tile") than descriptive clauses. For niche industrial defects that don't have clean English names, supply 1β2 positive/negative exemplar boxes instead of fighting text prompts. - Offload long video frame caches to CPU: Tracking beyond 500 frames at 1080p will climb linearly in GPU memory until OOM unless you offload historical frame tensors to host RAM or process in 150β300 frame sliding chunks.
- Prefer BF16 over FP16 on Ampere+ GPUs: On RTX 30/40 series, A100, and H100 cards,
torch.bfloat16avoids occasional FP16 overflow (NaNmasks) inside deep cross-attention layers while running at full tensor-core speed.
Paste any huggingface.co model, GGUF, or dataset URL into our converter to generate ready-to-run huggingface-cli, cURL, Wget, and Python commands.
π Related Engineering Guides
Deploy Qwen2.5-VL locally with dynamic resolution processing, structured OCR document parsing, video timeline analysis, and vLLM multimodal serving.
Deploy InternVL 2.5 vision-language models with dynamic high-resolution tiling, 4K OCR, TurboMind 4-bit quantization, and fast mirror weight downloads.
Deploy Meta LLaMA 3.2 Vision 11B and 90B with gated HF token mirror downloads, cross-attention adapter tuning, and OpenAI-compatible vLLM vision APIs.
Upgrade legacy BERT pipelines to ModernBERT with RoPE, unpadding, 8192 token context, FlashAttention-2 acceleration, and 2x faster dense RAG retrieval.