Meta SAM 3 Playground

Fix · SAM 3 / 3.1 · video tracking

Meta SAM Video Tracking Loses Objects Objects vanish behind obstacles, drift onto neighbours or swap IDs with look-alikes. Learn how SAM handles occlusion, which prompts track best, how to refine a track in a few clicks, and where the model’s real limits are.

lost and recovered
Animation of an object lost behind an obstacle and recoveredA tracked runner with a green mask passes behind a pillar. While hidden the mask disappears. When the runner reappears the track is not picked up again. A correction click on that frame with the same object ID restores the green mask for the rest of the clip. tracking · id 1 after the pillar: id 1 lostoccluded, then reappears looking different click on reappearance frame · same id 1 · re-propagate pillar
Illustration: occlusion, loss and a correction click.

Start here

What Kind of Tracking Failure?

You seeLikely causeGo to
Mask disappears after the object goes behind somethingOcclusion; not re-acquiredOcclusion
Object leaves the frame and isn’t picked up on returnRe-entry with changed lookOcclusion · Refine
Weak from the start, fails earlyPrompted on a poor framePrompts
Mask slowly grows onto background or a neighbourDriftRefine
IDs swap when similar objects crossLook-alike distractorsID swaps
Returning object gets a new IDDetected as newID swaps
Everything breaks at a scene cutDifferent shotCuts & long videos
Lost during fast motion or blurLarge jump between framesLimitations
Nothing tracked at allNot a tracking problemEmpty masks

Background

How SAM 3 Keeps Track

Knowing the mechanism explains when it fails and which fix will work.

tracker and detector
Animation of how SAM 3 keeps trackEach frame, the tracker carries objects forward using its memory of earlier frames, while the detector finds matches for the prompt. Detections are matched to tracks by overlap. Every sixteen frames, a confident detection that overlaps a track strongly is used to re-prompt the tracker, correcting drift. trackermemory of past frames detectorfinds prompt matches match by overlapkeep IDs masks + IDs every 16 frames: confident detection re-prompts the tracker
Simplified diagram of SAM 3 video tracking.
  • Tracker: carries each object forward using a memory of earlier frames, including the frames you prompted.
  • Occlusion signal: it predicts whether the object is visible, so a hidden object can have no mask without being dropped.
  • Detector: with text or example prompts, finds matches on every frame; matches are linked to tracks by overlap.
  • Self-correction: Meta periodically re-prompts the tracker with confident detections (every 16 frames by default in the paper) to recover from temporary failures.
  • Clicks you add are stored as strong memories, which is why one correction often fixes the rest of the clip.

Occlusion

Objects Hidden Behind Something

Short, partial occlusions usually recover by themselves. Long or full ones, especially when the object reappears looking different, need help.

Recovers on its own

  • Partly hidden for a few frames.
  • Reappears looking similar, near where it vanished.
  • No similar objects nearby.

Needs a correction

  • Fully hidden for a long stretch.
  • Turns around, changes pose or lighting while hidden.
  • Reappears next to a look-alike, or off-screen and back.
  • Fix: on the first frame it’s clearly back, add a positive click with the same object ID, then propagate forward from there.
  • Occluder grabbed instead? Add a negative click on the occluder.
  • Expect gaps: no mask while hidden is correct behaviour, not an error; fill gaps in post if your use needs it.

Prompts

Prompts That Track Well

A track is only as good as its starting point. Prompt where the object is clearest, then propagate both ways.

best frame
Animation of prompting on the clearest frameA row of twelve frames. Prompting on frame 0, where the object is half hidden, gives a weak track that fails later. Prompting on frame 6, where it is fully visible, and propagating both backward and forward gives a good mask on every frame. frames 0 → 11 prompt on frame 0 (half hidden) → lost from frame 5 prompt prompt on frame 6 (fully visible), propagate both ways propagation_direction="both", start_frame_index=6 good maskweaklost
Illustration of prompting on the clearest frame.
  • Pick the frame: fully visible, sharp, not overlapping similar objects; it doesn’t need to be frame 0.
  • Propagate both ways from that frame (propagation_direction="both").
  • One specific object: click it; text prompts follow every instance and can swap among look-alikes.
  • Many of a kind: text or an example box, then remove unwanted IDs.
  • Add a second prompt on a frame where the object looks very different (front vs back).
  • Prompt basics: select one object in video

Refinement

Refine a Track in a Few Clicks

Corrections are just more prompts for the same object ID on the frames that went wrong.

refinement loop
Animation of the refinement loopA timeline of a tracked object shows a stretch of lost frames. A scan flags the first bad frame. A correction click is added there with the same object ID, propagation runs again from that frame, and the lost stretch turns good. object id 1 across the clip 1 · scan: frames 5–8 empty 2 · click on frame 5, obj_id=1 3 · propagate from frame 5 → fixed repeat until no flagged frames: scan → first bad frame → click (+ / −) → re-propagate fix the earliest problem first; later ones often disappear
Illustration of scan, click and re-propagate.
  1. 1Scanthe masks for empty frames, sudden size changes and jumps (script).
  2. 2Go to the first bad frame,not the worst one.
  3. 3Click:positive on the object; negative on whatever it leaked onto.
  4. 4Re-propagatefrom that frame forward.
  5. 5Removeghost or duplicate IDs; repeat until the scan is clean.

ID swaps

Look-Alikes, ID Swaps and New IDs

Similar objects that touch or cross are the hardest case for any tracker.

identity swap
Animation of an identity swap between similar objectsTwo similar players, green id 1 and blue id 2, run toward each other and cross. After crossing their colours swap, so id 1 now follows the wrong player. A positive click on the right player and a negative click on the other, both for id 1, fixes the identities. two look-alikes approach and cross after crossing: ids swapped id 1: + click on the right player, − on the other
Illustration of an ID swap and its fix.
  • Swap after crossing: on the first swapped frame, positive click on the right object and negative on the other, for each affected ID.
  • Prompt each look-alike separately with its own ID before they meet.
  • Returning object gets a new ID: refine the old ID on the reappearance frame and remove the new one, or link IDs in post-processing.
  • Crowds: try SAM 3.1, which Meta reports handles crowded scenes better.

Cuts & long videos

Scene Cuts and Long Videos

SAM 3’s concept task is defined on short clips (up to about 30 seconds in the paper). Edited videos and long recordings need splitting.

  • Scene cuts: a different shot isn’t the same view; split at cuts and prompt each shot.
  • Long recordings: process in chunks, re-prompt each chunk, then link IDs across chunks in your own code (by position or appearance).
  • Memory and speed also improve with chunks: memory · speed

Code

Code: Find Bad Frames, Correct, Re-Propagate

find_bad_frames.py

# find_bad_frames.py: flag frames where a track was lost, jumped or leaked
import numpy as np

def iou(a, b):
    inter = np.logical_and(a, b).sum()
    union = np.logical_or(a, b).sum()
    return inter / union if union else 1.0

def find_bad_frames(masks, min_area=50, max_area_change=0.5, min_iou=0.3):
    """masks: {frame_index: bool array} for ONE object id, from propagation."""
    flags, prev = {}, None
    for f in sorted(masks):
        m = np.asarray(masks[f], dtype=bool)
        area = int(m.sum())
        why = []
        if area < min_area:
            why.append("lost (empty)")
        elif prev is not None and prev.sum() >= min_area:
            change = abs(area - prev.sum()) / prev.sum()
            if change > max_area_change:
                why.append(f"area {'grew' if area > prev.sum() else 'shrank'} {change:.0%}")
            if iou(m, prev) < min_iou:
                why.append(f"jumped (IoU {iou(m, prev):.2f})")
        if why:
            flags[f] = why
        prev = m
    return flags

# flags = find_bad_frames({f: out[1] for f, out in masks_by_frame.items()})
# first_bad = min(flags) if flags else None   # correct this frame first

official sam3 · correct and re-propagate

# official sam3 video predictor: correct id 1 on its first bad frame, then re-propagate
import torch

def correct(predictor, sid, frame, obj_id, pos, neg=()):
    pts = list(pos) + list(neg)
    labels = [1] * len(pos) + [0] * len(neg)
    predictor.handle_request(dict(
        type="add_prompt", session_id=sid, frame_index=frame, obj_id=obj_id,
        points=torch.tensor(pts, dtype=torch.float32),      # check coordinate scale in the video notebook
        point_labels=torch.tensor(labels, dtype=torch.int32)))

correct(predictor, sid, frame=first_bad, obj_id=1, pos=[(0.62, 0.48)], neg=[(0.70, 0.50)])

masks_by_frame = {}
for r in predictor.handle_stream_request(dict(
        type="propagate_in_video", session_id=sid,
        propagation_direction="forward", start_frame_index=first_bad)):
    masks_by_frame[r["frame_index"]] = r["outputs"]

# remove a ghost or duplicate track
predictor.handle_request(dict(type="remove_object", session_id=sid, obj_id=7))

official sam3 · prompt mid-clip, propagate both ways

# prompt on the clearest frame and propagate both ways
predictor.handle_request(dict(type="add_prompt", session_id=sid, frame_index=60, text="dog"))
for r in predictor.handle_stream_request(dict(
        type="propagate_in_video", session_id=sid,
        propagation_direction="both", start_frame_index=60)):
    masks_by_frame[r["frame_index"]] = r["outputs"]

Transformers · Sam3TrackerVideo correction

# Transformers tracker: add a correction click for object 1 on a later frame, then re-propagate
processor.add_inputs_to_inference_session(
    inference_session=session, frame_idx=first_bad, obj_ids=1,
    input_points=[[[[220, 280], [300, 260]]]], input_labels=[[[1, 0]]])   # pixels; + and −
for out in model.propagate_in_video_iterator(session):
    ...

ffmpeg · find and split scene cuts

# split at scene cuts, then track each shot separately (re-prompt per shot)
ffmpeg -i input.mp4 -filter:v "select='gt(scene,0.35)',showinfo" -f null - 2>&1 | grep pts_time
# then cut at those times, e.g.:
ffmpeg -i input.mp4 -ss 0 -to 12.4 -c copy shot_01.mp4

Request names follow Meta’s video notebook; confirm point coordinate scale and options for your commit. Full pipeline: video segmentation with Python.

Limitations

What SAM 3 Can’t Fully Solve Yet

Some failures are limits of the model, not settings. Plan for them.

LimitWhat to do
Fast motion and heavy blurHigher frame rate source, more corrections, or a motion-aware tracker
Many identical objects that interact (herds, crowds, swarms)Expect ID swaps; correct key frames; post-process identities
Long disappearance with big appearance changeRe-prompt on return; link IDs yourself
Long videos and editsSplit into shots and chunks
Specialised domains (surgery, microscopy)Fine-tuning or domain-specific SAM extensions
Thin, transparent or tiny objectsHigher resolution and corrections; see limitations

Research add-ons (for example re-prompting with object retrieval, or occlusion-aware memory) improve some of these cases but aren’t part of Meta’s release. Fine-tuning: fine-tune SAM.

Questions

Tracking FAQ

Why does SAM lose an object after it goes behind something?

While hidden, there’s nothing to match. If it comes back looking different or next to a similar object, the tracker may not pick it up again. Add a click on the frame where it reappears, with the same object ID.

How do I fix one bad stretch without redoing the whole video?

Find the first wrong frame, add a positive (and if needed negative) click there for the same object ID, and propagate again from that frame.

Should I prompt with text or with a click?

Text finds and re-detects every instance of a concept, which helps re-acquire objects but can swap identities among look-alikes. A click follows one specific object. For a single important object, click it.

Which frame should I prompt on?

One where the object is fully visible, sharp and not touching similar objects. Then propagate in both directions from there.

Does SAM 3.1 track better than SAM 3?

Meta reports better crowded-scene handling and video segmentation results on 6 of 7 benchmarks; it’s worth trying for scenes with many similar objects.

Why does a returning object get a new ID?

With concept prompts, a reappearing object can be detected as new. Keep IDs consistent by refining with the original ID, or link IDs afterwards in your own code.

Keep reading