Meta SAM 3 Playground

Fix · SAM 3 / 3.1 · no detections

SAM Detects No Objects or Returns Empty Masks Zero masks has two kinds of cause. Setup problems (image paths and loading, permissions, broken downloads, version mismatches) make SAM find nothing anywhere. Prompt problems (wording, threshold, coordinates) make it miss specific things.

0 masks → 2 masks
Animation of an empty result turning into masksA street photo with two red cars and the prompt “car” returns zero masks. A checklist ticks through setup (image, weights, versions) and then prompt and threshold. After lowering the threshold, both cars get masks. text › “car” 0 masks 2 masks · threshold 0.5 → 0.35 image loads OKweights completeversions matchprompt simplescore 0.42 < 0.5 setup first, then prompt and threshold
Illustration: rule out setup, then tune prompt and threshold.

Start here

One Question Splits the Problem

Is it empty for every image and every prompt, or only for some?

triage
Animation of the first triage questionA question asks whether results are empty for every image and every prompt. If yes, the path leads to setup causes: image loading, weights and versions. If only some images or prompts are empty, the path leads to prompt, threshold, object size and coordinates. empty for EVERYTHING? yessetup problem· image loading / paths· weights not fully loaded· version mismatch no, someprompt / data problem· prompt wording, threshold· small / hidden objects· coordinates, frames
Illustration of the first triage question.

Setup · paths

Image Paths and Loading

If the model gets the wrong pixels, it can’t find the right objects, and many loading mistakes don’t raise errors.

loading mistakes
Animation of image-loading problemsThe same photo of a red car is shown as the model would receive it after three loading mistakes: colours swapped by reading with OpenCV as BGR so the car turns blue and “red car” finds nothing, a black frame from a wrong or empty file, and a photo rotated sideways because camera orientation was ignored. The last panel shows the correctly loaded RGB image. BGR read: “red car” is now blue all zeroswrong / empty file → black image EXIF rotation ignored → sideways load as RGB, apply EXIF orientation, and check the array
Illustration of colour, blank and rotation mistakes.
  • Wrong file: print the resolved path and image size; batch loops often pick up thumbnails or hidden files.
  • BGR colours: cv2.imread returns BGR; colour prompts like “red car” then fail. Convert to RGB.
  • Not RGB: RGBA, grayscale or palette images → .convert("RGB"); scale 16-bit images to 8-bit first, or they turn white.
  • Sideways photos: apply EXIF orientation (ImageOps.exif_transpose).
  • Permissions: unreadable files skipped by a try/except become silent empty results; an unwritable output folder means masks are never saved and look “empty”.

Setup · downloads

Broken Downloads and Partly Loaded Weights

A model with some layers missing still runs. It just finds nothing, or nonsense.

SignWhat to do
Load report lists many MISSING / UNEXPECTED keys (e.g. all text-encoder layers)Those layers are randomly initialised, so text prompts find nothing. Match library and checkpoint versions (versions); don’t ignore the report.
Worked last week, empty today, “nothing changed”A library update or new model revision. Pin package versions, and pin the model revision you validated.
Checkpoint smaller than expected or fails checksumRe-download and verify. Checkpoint downloads
Ultralytics + sam3.1_multiplex.pt gives nothing usefulVersions before 8.4.148 could load parts with random weights. Upgrade.
Access error swallowed by your codeMake sure you’re not falling back to an empty model. Model access

Setup · versions

Version and Interface Mismatches

Using a model or interface that can’t do what you ask returns empty results rather than errors.

MismatchFix
Text prompt with SAM 1 or SAM 2They don’t understand text. Use SAM 3 or 3.1.
Ultralytics SAM("sam3.pt") with textSAM takes points and boxes; text needs SAM3SemanticPredictor.
Transformers Sam3TrackerModel with textThe tracker takes clicks/boxes; text needs Sam3Model (images) or Sam3VideoModel.
Old Transformers with current facebook/sam3 files (or the reverse)Upgrade Transformers; check the load report is clean.
SAM 3.1 checkpoint with older sam3 codeUpdate the code. Checkpoint versions
Ultralytics: wrong clip packageUninstall clip, install Ultralytics’ CLIP fork.

Prompt

Prompt Wording

SAM 3 matches short noun phrases. Wording that’s too long, too rare or too vague can score below the threshold.

Instead ofTry
“the car that is parked next to the tree on the left”“car”, then pick one: select specific objects
“automobile”, “velocipede”Common words: “car”, “bicycle”
“object”, “thing”, “stuff”Name the category
“cars” finds nothingTry the singular, “car”, and the reverse
Non-English wordsEnglish noun phrases
“crack in concrete” (rare domain)Add an example box, or fine-tune: fine-tuning

30+ tested phrasings: prompt examples

Threshold

The Confidence Threshold

An empty result is often a score just below the cut-off. Look at the scores before changing anything else.

scores vs threshold
Animation of scores and the confidence thresholdFive candidate detections have scores 0.42, 0.38, 0.12, 0.05 and 0.31. At threshold 0.5 none pass, so the result is empty. Lowering the line to 0.35 lets two cars through; at 0.3 a third, smaller car also passes. 0.42cand 10.38cand 20.12cand 30.05cand 40.31cand 5 threshold 0.50 → 0 masksthreshold 0.35 → 2 masksthreshold 0.30 → 3 masks print the top scores before deciding the prompt failed
Illustration of scores and the threshold line.
  • Official sam3: Sam3Processor(confidence_threshold=0.5) by default; set_confidence_threshold re-filters without re-running.
  • Transformers: the threshold you pass to post_process_instance_segmentation; the docs use 0.5.
  • APIs and ComfyUI: usually a confidence_threshold or threshold input, often 0.5.
  • Try 0.3 to see near-misses, then raise it until false matches go away.
  • mask_threshold is different: it shapes each mask, and set very high it can shrink masks to nothing.

Code

Re-filter at a Lower Threshold

official sam3

# official sam3 processor: re-filter without re-running the model
state = processor.set_image(image)
state = processor.set_text_prompt(prompt="car", state=state)
print(len(state["scores"]), "at 0.5")
state = processor.set_confidence_threshold(0.3, state)   # see near-misses
print(len(state["scores"]), "at 0.3", [round(float(s), 2) for s in state["scores"]])

Hard objects

Small, Hidden or Unusual Objects

  • Tiny objects: SAM 3 resizes images to a fixed square (1008 px in the official processor), so small objects shrink to a few pixels. Crop or tile the image, then segment each piece.
  • Mostly hidden objects: add a click or box on the visible part.
  • Unusual domains (microscopy, satellite, X-ray): add an example box; for repeated use, fine-tune.
  • Very dark, blurred or low-contrast images: brighten or sharpen a copy for segmentation.
  • Known limits: limitations

Clicks & boxes

Clicks or Boxes Return Nothing

Visual prompts fail quietly when the coordinates are in the wrong format.

coordinate mix-ups
Animation of coordinate mix-upsA click meant for a car at pixel 620, 410 is sent in different formats. Sent as pixels where 0 to 1 values are expected, it lands off the image. Sent with x and y swapped, it lands on the road. Sent correctly, it lands on the car and returns a mask. image 800 × 360 · car at (620, 410) in full-size pixels pixels sent where 0–1 expected → off the image (y, x) instead of (x, y) → empty road right format → mask
Illustration of coordinate format mistakes.
  • Pixels vs 0–1: some interfaces want normalised values, others pixels.
  • Order: points are (x, y); NumPy arrays index [y, x].
  • Box format: Transformers uses pixel x0, y0, x1, y1; Meta’s geometric prompts use normalised centre-x, centre-y, width, height.
  • Labels: 1 = include, 0 = exclude; all zeros selects nothing.
  • Resized display: clicks on a scaled preview must be converted back to full-size pixels.
  • Examples per interface: prompt examples

Video

Empty Masks in Video

SymptomFix
Nothing on any framePrompt a frame where the object is clearly visible; check frames load (folder not empty, names sort in order)
Mask only on the prompted frameYou didn’t propagate; run the propagate step
Object disappears partwayTracking lost it: tracking loses objects
Empty after out-of-memory errorsCaught exceptions hide failures: CUDA out of memory

End-to-end example: video segmentation with Python

Debug

Debug Scripts

First confirm the image, then confirm the model can find something obvious, and only then tune prompts.

check_image.py

# check_image.py: is the model seeing what you think it sees?
import numpy as np
from PIL import Image, ImageOps

def load_rgb(path):
    img = Image.open(path)
    img = ImageOps.exif_transpose(img)          # apply camera rotation
    if img.mode.startswith("I"):                # 16/32-bit: scale to 8-bit first, or it clips to white
        a = np.asarray(img, dtype=np.float32)
        img = Image.fromarray((255 * (a - a.min()) / max(np.ptp(a), 1)).astype(np.uint8))
    return img.convert("RGB")                   # drop alpha, fix grayscale / palette

def describe(path):
    img = load_rgb(path)
    a = np.asarray(img)
    flags = []
    if a.size == 0 or min(img.size) < 32: flags.append("tiny image")
    if a.std() < 2: flags.append("almost uniform (black/blank?)")
    if a.mean() < 8: flags.append("very dark")
    print(f"{path}: {img.size[0]}x{img.size[1]} {img.mode} mean={a.mean():.0f} std={a.std():.0f}",
          "⚠ " + ", ".join(flags) if flags else "✓")
    return img

# OpenCV users: cv2.imread gives BGR. Convert before passing to SAM:
# rgb = cv2.cvtColor(cv2.imread(path), cv2.COLOR_BGR2RGB)

sanity_test.py · Transformers

# sanity_test.py: does the model find ANYTHING? (Transformers)
import torch
from PIL import Image
from transformers import Sam3Processor, Sam3Model

model = Sam3Model.from_pretrained("facebook/sam3", device_map="auto")   # read the load report it prints
processor = Sam3Processor.from_pretrained("facebook/sam3")

image = load_rgb("people.jpg")                       # a photo that obviously contains people
inputs = processor(images=image, text="person", return_tensors="pt").to(model.device)
with torch.no_grad():
    out = model(**inputs)

scores = out.pred_logits.sigmoid()[0]
if out.presence_logits is not None:
    print("presence:", round(out.presence_logits.sigmoid().item(), 3))
    scores = scores * out.presence_logits.sigmoid()[0]
print("top scores:", [round(s, 3) for s in scores.topk(5).values.tolist()])

r = processor.post_process_instance_segmentation(
    out, threshold=0.3, mask_threshold=0.5, target_sizes=inputs.get("original_sizes").tolist())[0]
print("masks at 0.3:", len(r["masks"]))

If the sanity test finds people with good scores, setup is fine and the issue is your prompt, threshold or data. If it finds nothing, go back to weights and versions. All other problems: troubleshooting.

Questions

Empty Masks FAQ

Why does SAM 3 return no masks for a clearly visible object?

Most often the score is just under the threshold, the prompt is phrased in a way SAM 3 doesn’t match, or the object is very small. If nothing is ever found, suspect setup: the image, the weights or a version mismatch.

What confidence threshold should I use?

Meta’s processor defaults to 0.5. Drop to 0.3 to see near-misses, then raise it until false matches disappear.

SAM 3 returned nothing for every image. What’s wrong?

Usually setup: images not loading as you think, an incomplete or partly loaded checkpoint, or library versions that don’t match the weights. Run the sanity test on this page.

Can SAM 3 tell me an object isn’t there?

Yes. Its presence check is designed to return nothing, with low scores, when the prompted concept isn’t in the image. An empty result can be correct.

Why do my clicks or boxes give empty masks?

Coordinates in the wrong format: pixels vs 0–1 values, x and y swapped, or a box format the interface doesn’t expect.

Does SAM 2 support text prompts?

No. Text prompts need SAM 3 or SAM 3.1 and the interface that accepts text.

Keep reading