Guide · SAM 3 / 3.1 · examples
SAM 3 Prompt Examples: Text and Visual Prompts What to type, where to draw boxes and when to click, with real examples by industry, side-by-side weak vs better prompts, and the exact code to send each prompt type.
At a glance
SAM 3 Prompt Types at a Glance
Concept prompts find every match. Instance prompts select one object. You can mix them.
| Prompt | Example | Returns | Use when |
|---|---|---|---|
| Text | “yellow taxi” | Every matching instance | You can name it |
| Positive exemplar box | Box around one washer | Every look-alike | It’s hard to name |
| Negative exemplar box | Box around the oven handle | Removes look-alikes | Text catches too much |
| Text + boxes | “handle” + negative box | Refined concept | Best precision |
| Clicks (+ / −) | Click person, −click bag | One object | Cut-outs, editing |
| Single box (instance) | Box around one car | One object | Quick single selection |
Why these work, and the concepts behind them: SAM 3 prompts explained. SAM 3.1 uses the same prompts.
Text prompts
Text Prompt Examples by Industry
Filter by domain. Each row shows a prompt that tends to disappoint and a better one.
| Scene | Weak prompt | Better prompt | Why |
|---|---|---|---|
| Retail shelf | “products” | “cereal box” | Product type, not a vague category |
| E-commerce photo | “thing” | “leather handbag” | Material + object for clean cut-outs |
| Street camera | “vehicles” | “yellow taxi” | One attribute isolates a subgroup |
| Parking lot | “car details” | “license plate” | Name the exact part you need |
| Football match | “people” | “player” | Specific role noun |
| Tennis broadcast | “the ball in play” | “tennis ball” | Name the object, not the event |
| Wildlife camera | “animal” | “deer” | Species name beats a category |
| Drone over farm | “plants” | “sheep” | Name what is visible from above |
| Greenhouse | “fruit” | “ripe tomato” | Colour/state adjective |
| Field scan | “problems” | “weed” | Concrete noun, not an abstract issue |
| Building site | “safety gear” | “hard hat” | Name the item |
| Production line | “defects” | “scratch” | Visible symptom; fine-tune for subtle defects |
| Scanned form | “text” | “signature” | Specific element of the page |
| Slide screenshot | “images” | “chart” | Element type |
| Restaurant plate | “food” | “french fries” | Dish component |
| Microscopy | “cells” | “cell nucleus” | Domain term; validate carefully and consider fine-tuning |
Rule of thumb: a visible noun plus at most one attribute (colour, material, type or state). These are guidance patterns, not guaranteed results; test on your own images.
Be specific
Add One Attribute to Narrow Results
The same image, three prompts. Small wording changes decide which instances match.
- Colour: “red car”, “white van”.
- Material: “glass bottle”, “wooden chair”.
- Type: “sports car”, “cargo ship”.
- Part: “wheel”, “door handle”, “license plate”.
- Stop at one or two words of detail: longer phrases rarely help and can hurt.
Visual prompts
Positive Exemplar Boxes: “Find More Like This”
Draw a box around one example; SAM 3 finds the rest. No text needed.
- Tight boxes: hug the example object; avoid background.
- Pick a typical example: not the blurry or cut-off one.
- Varied looks? add 2–3 positive boxes on different examples.
- Great for: custom parts, product SKUs, logos, odd shapes.
- Plus text: “square bottle” + an example box is more robust than either alone.
Visual prompts
Negative Exemplar Boxes: “But Not That”
When text catches look-alikes, box one of them as negative.
- Example: text “handle”, negative box on the oven handle → cupboard handles only.
- One negative often fixes a whole class of false positives.
- Don’t overdo it: each extra prompt costs time; try a higher confidence threshold first.
- Negation in words doesn’t work: “not the oven handle” won’t; a negative box will.
Instance prompts
Clicks: Select Exactly One Object
Positive clicks add, negative clicks remove. Ideal for cut-outs and edits.
- Start with one click near the centre of the object.
- Mask too big? add a negative click on the extra part.
- Mask too small? add a positive click on the missing part.
- Or a box: one box around the object selects it in one go.
- More: select specific objects
Recipes
Prompt Recipes for Common Jobs
Every instance of a thing
Inventory, counting, auto-labelling
text: "pallet"Only one subgroup
Colour or type within a class
text: "yellow taxi"Something hard to name
Odd parts, custom products
positive box on one example
(no text)Remove look-alikes
Similar objects you don’t want
text: "handle"
negative box: oven handleSeveral examples
Varied appearance
positive boxes on 2–3 examplesExactly one object
Cut-out, editing
one click (or box) on it
+ negative click on extrasTwo concepts at once
Separate classes, one image
text: "person", then "bicycle"
(reuse the image state)Track in video
Sports, traffic, wildlife
text on frame 0: "player"
click to fix driftComfyUI shorthand
Limit counts per subject
eye:2, window panels:4The last recipe uses ComfyUI’s native syntax (comma-separated subjects, :N max detections, 32-token limit). ComfyUI setup
Code
Send Each Prompt Type in Code
Same prompts, three interfaces. Mind the box format: each one expects coordinates differently.
official sam3 repo · text + negative box (normalized cx, cy, w, h)
from PIL import Image
from sam3.model_builder import build_sam3_image_model
from sam3.model.sam3_image_processor import Sam3Processor
processor = Sam3Processor(build_sam3_image_model())
image = Image.open("kitchen.jpg").convert("RGB")
W, H = image.size
state = processor.set_image(image)
def norm_cxcywh(x0, y0, x1, y1): # pixel xyxy → normalized cx, cy, w, h
return [(x0 + x1) / 2 / W, (y0 + y1) / 2 / H, (x1 - x0) / W, (y1 - y0) / H]
# 1. text: every handle
state = processor.set_text_prompt(state=state, prompt="handle")
# 2. negative exemplar: but not the oven handle
state = processor.add_geometric_prompt(state=state, box=norm_cxcywh(40, 183, 318, 204), label=False)
masks, boxes, scores = state["masks"], state["boxes"], state["scores"]
# start again with a different prompt on the same image
processor.reset_all_prompts(state)Hugging Face Transformers · pixel xyxy boxes, labels 1 / 0
from transformers import Sam3Model, Sam3Processor
model = Sam3Model.from_pretrained("facebook/sam3", device_map="auto")
processor = Sam3Processor.from_pretrained("facebook/sam3")
# A) text only
inputs = processor(images=image, text="handle", return_tensors="pt")
# B) positive exemplar boxes only (pixel xyxy), no text
inputs = processor(images=image, input_boxes=[[[59, 144, 76, 163], [87, 148, 104, 159]]],
input_boxes_labels=[[1, 1]], return_tensors="pt")
# C) text + negative box: handles, except the oven handle
inputs = processor(images=image, text="handle", input_boxes=[[[40, 183, 318, 204]]],
input_boxes_labels=[[0]], return_tensors="pt")
outputs = model(**inputs.to(model.device))
results = processor.post_process_instance_segmentation(
outputs, threshold=0.5, mask_threshold=0.5, target_sizes=inputs.get("original_sizes").tolist())[0]Ultralytics · text, exemplar boxes, clicks
from ultralytics import SAM
from ultralytics.models.sam import SAM3SemanticPredictor
p = SAM3SemanticPredictor(overrides=dict(model="sam3.pt", task="segment", mode="predict", conf=0.25))
p.set_image("street.jpg")
p(text=["yellow taxi"]) # concept from text
p(text=[('"person with red cloth"', '"person with blue cloth"')]) # several phrases
p(bboxes=[[539, 599, 589, 639]]) # concept from an example box
sam = SAM("sam3.pt") # single-object, SAM 2 style
sam("street.jpg", points=[[378, 185]], labels=[1]) # one positive click
sam("street.jpg", bboxes=[[340, 160, 410, 200]]) # one box → one objectOfficial repo method names follow Meta’s image notebook (sam3_image_predictor_example.ipynb); confirm them for your version. Transformers box examples follow the official model card. Setup: Python tutorial · Hosted APIs use their own field names: API guide
Video
Video Prompt Examples
Prompt once, track everywhere; add clicks only where something goes wrong.
inside a video session
# text on frame 0 finds every player
predictor.handle_request(dict(type="add_prompt", session_id=sid, frame_index=0, text="player"))
# later: fix one object with a click (check coordinate scale in the video notebook)
predictor.handle_request(dict(type="add_prompt", session_id=sid, frame_index=120,
points=[[0.42, 0.55]], point_labels=[1], obj_id=2))- Text on an early frame where all targets are visible.
- New arrivals are picked up by the detector with text prompts.
- Drift: a positive click with the object’s
obj_idon the bad frame, then propagate again. - Full script: video segmentation with Python
Fix bad prompts
Prompts That Fail, and What to Use Instead
| Prompt | Problem | Do this instead |
|---|---|---|
| “the person holding the red umbrella” | Relationship sentence | “red umbrella” + click the person, or SAM 3 Agent |
| “not the red car” | Negation | “car” + negative box on the red car |
| “three dogs” | Counting in the prompt | “dog”, then keep the top-3 scores |
| “danger” | Abstract idea | Name the visible thing: “fire”, “broken glass” |
| “stuff on the table” | Vague category | List items: “cup”, then “plate” |
| “Gucci logo” | Brand-specific | Positive box on one logo as an exemplar |
Still empty? Empty masks · Known gaps: limitations
Questions
Prompt Examples FAQ
What is a good SAM 3 text prompt?
A short noun phrase naming what you can see, optionally with one attribute: “yellow taxi”, “hard hat”, “ripe tomato”. SAM 3 returns every matching instance.
What are visual prompts in SAM 3?
Boxes and clicks. Exemplar boxes (positive or negative) tell SAM 3 which concept to find across the whole image; clicks and single boxes select one specific object, SAM 2 style.
How do I exclude look-alike objects?
Add a negative exemplar box around a look-alike. For example, prompt “handle” and put a negative box on the oven handle to keep only the other handles.
Can I combine text and boxes?
Yes. Text plus positive boxes narrows the concept; text plus negative boxes removes look-alikes. In Transformers, pass text, input_boxes and input_boxes_labels together.
Why does a long sentence prompt fail?
SAM 3 is built for short noun phrases. Relationships like “the person holding the red umbrella” need SAM 3 Agent with a multimodal LLM, or a short phrase plus a box.
Do prompts work the same in SAM 3.1?
Yes. SAM 3.1 uses the same prompt types; its changes are in multi-object video tracking.
What box format does SAM 3 use?
It depends on the interface: Transformers and Ultralytics take pixel [x1, y1, x2, y2]; the official sam3 processor’s geometric prompt takes a normalized [cx, cy, w, h] box. Convert before sending.