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.
Start here
One Question Splits the Problem
Is it empty for every image and every prompt, or only for some?
- Empty for everything, even “person” on a photo of people → setup: image, weights, versions.
- Empty for some prompts or images → prompt, threshold, hard objects.
- Empty with clicks or boxes → coordinates.
- Empty in video only → frames and prompts.
- Remember: SAM 3 is built to return nothing, with low scores, when the concept really isn’t there.
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.
- Wrong file: print the resolved path and image size; batch loops often pick up thumbnails or hidden files.
- BGR colours:
cv2.imreadreturns 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/exceptbecome 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.
| Sign | What 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 checksum | Re-download and verify. Checkpoint downloads |
Ultralytics + sam3.1_multiplex.pt gives nothing useful | Versions before 8.4.148 could load parts with random weights. Upgrade. |
| Access error swallowed by your code | Make 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.
| Mismatch | Fix |
|---|---|
| Text prompt with SAM 1 or SAM 2 | They don’t understand text. Use SAM 3 or 3.1. |
Ultralytics SAM("sam3.pt") with text | SAM takes points and boxes; text needs SAM3SemanticPredictor. |
Transformers Sam3TrackerModel with text | The 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 code | Update the code. Checkpoint versions |
Ultralytics: wrong clip package | Uninstall 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 of | Try |
|---|---|
| “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 nothing | Try the singular, “car”, and the reverse |
| Non-English words | English 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.
- Official sam3:
Sam3Processor(confidence_threshold=0.5)by default;set_confidence_thresholdre-filters without re-running. - Transformers: the
thresholdyou pass topost_process_instance_segmentation; the docs use 0.5. - APIs and ComfyUI: usually a
confidence_thresholdorthresholdinput, often 0.5. - Try 0.3 to see near-misses, then raise it until false matches go away.
mask_thresholdis 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.
- 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
| Symptom | Fix |
|---|---|
| Nothing on any frame | Prompt a frame where the object is clearly visible; check frames load (folder not empty, names sort in order) |
| Mask only on the prompted frame | You didn’t propagate; run the propagate step |
| Object disappears partway | Tracking lost it: tracking loses objects |
| Empty after out-of-memory errors | Caught 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.