{
 "schema_version": 1,
 "generated": "2026-10-31",
 "id": "facebookresearch-sam2--segment-objects-in-an-image-with-sam2",
 "repo": "facebookresearch/sam2",
 "repo_url": "https://github.com/facebookresearch/sam2",
 "repo_slug": "facebookresearch-sam2",
 "title": "Segment an object in an image from a click",
 "page_title": "How to segment an object in an image from a click with Sam2",
 "summary": "Install SAM 2, download checkpoints and get masks for an image from point or box prompts.",
 "who": "A developer cutting objects out of product photos.",
 "problem": "Hand masking objects is slow and inconsistent.",
 "outcome": "Masks for the objects you prompted.",
 "steps": [
  "Run `git clone https://github.com/facebookresearch/sam2.git && cd sam2` then `pip install -e .`",
  "Download checkpoints with `./download_ckpts.sh` inside the checkpoints folder",
  "Build a SAM2ImagePredictor from configs/sam2.1/sam2.1_hiera_l.yaml and ./checkpoints/sam2.1_hiera_large.pt",
  "Call predictor.set_image with your image and predictor.predict with your prompts"
 ],
 "agent_prompt": "Using facebookresearch/sam2, install it with `pip install -e .`, download the checkpoints, and write a script that loads SAM2ImagePredictor and saves a mask PNG for the object at a point I give in <my image>.",
 "agents": [
  "claude-code",
  "codex",
  "cursor",
  "gemini-cli"
 ],
 "difficulty": "Intermediate",
 "time": "45 minutes",
 "basis": "readme",
 "caveat": "Install compiles a CUDA extension; if it fails SAM 2 still works with some post-processing limited.",
 "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": true,
 "score": 1.0,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/facebookresearch-sam2/segment-objects-in-an-image-with-sam2/",
 "md": "https://dedupedai.com/use-cases/facebookresearch-sam2/segment-objects-in-an-image-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--segment-objects-in-an-image-with-sam2.json",
 "api_version": "v1"
}
