{
 "schema_version": 1,
 "generated": "2026-10-31",
 "id": "facebookresearch-sam2--track-an-object-through-a-video-with-sam2",
 "repo": "facebookresearch/sam2",
 "repo_url": "https://github.com/facebookresearch/sam2",
 "repo_slug": "facebookresearch-sam2",
 "title": "Track an object through a video",
 "page_title": "How to track an object through a video with Sam2",
 "summary": "Prompt an object on one frame and propagate its mask through the whole video.",
 "who": "A video editor or analyst who needs a mask on a moving object.",
 "problem": "Rotoscoping frame by frame takes hours.",
 "outcome": "Masklets for the object across every frame.",
 "steps": [
  "Install SAM 2 and download checkpoints as in the README",
  "Create a predictor with build_sam2_video_predictor and call predictor.init_state on your video",
  "Add a point or box with predictor.add_new_points_or_box on one frame",
  "Loop over predictor.propagate_in_video(state) to get masks for every frame"
 ],
 "agent_prompt": "With facebookresearch/sam2, write a script that uses build_sam2_video_predictor, adds a box prompt on frame 0 of <my video frames folder>, propagates with propagate_in_video, and writes an overlay video.",
 "agents": [
  "claude-code",
  "codex",
  "cursor",
  "gemini-cli"
 ],
 "difficulty": "Advanced",
 "time": "1 to 2 hours",
 "basis": "readme",
 "caveat": "Setting vos_optimized=True enables full model compilation for a major speedup, per the latest updates.",
 "category": "Research",
 "tags": [
  "Research"
 ],
 "lang": "jupyter notebook",
 "requirements": [
  "Python 3.10 or newer with torch 2.5.1 and torchvision 0.20.1 or newer",
  "An NVIDIA GPU with CUDA is recommended; Windows users should use WSL with Ubuntu",
  "A model checkpoint from the download script or Hugging Face"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.9,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/facebookresearch-sam2/track-an-object-through-a-video-with-sam2/",
 "md": "https://dedupedai.com/use-cases/facebookresearch-sam2/track-an-object-through-a-video-with-sam2/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/facebookresearch-sam2--track-an-object-through-a-video-with-sam2.json",
 "api_version": "v1"
}
