{
 "schema_version": 1,
 "generated": "2026-10-31",
 "id": "facebookresearch-sam2--load-sam2-from-hugging-face",
 "repo": "facebookresearch/sam2",
 "repo_url": "https://github.com/facebookresearch/sam2",
 "repo_slug": "facebookresearch-sam2",
 "title": "Load SAM 2 from Hugging Face without the checkpoint script",
 "page_title": "How to load SAM 2 from Hugging Face without the checkpoint script with Sam2",
 "summary": "Use from_pretrained to pull facebook/sam2-hiera-large straight from the Hub.",
 "who": "A developer prototyping in a notebook who wants the shortest path.",
 "problem": "Managing checkpoint files by hand is friction for a quick test.",
 "outcome": "A working image or video predictor loaded from the Hub.",
 "steps": [
  "Install SAM 2 with `pip install -e .` from the cloned repo",
  "Install the Hub client with `pip install huggingface_hub`",
  "Call SAM2ImagePredictor.from_pretrained(\"facebook/sam2-hiera-large\") or SAM2VideoPredictor.from_pretrained",
  "Run set_image and predict as usual"
 ],
 "agent_prompt": "Using facebookresearch/sam2, install `pip install huggingface_hub`, load SAM2ImagePredictor.from_pretrained(\"facebook/sam2-hiera-large\") in a notebook, and segment the main object in <my image>.",
 "agents": [
  "claude-code",
  "codex",
  "cursor",
  "gemini-cli"
 ],
 "difficulty": "Beginner",
 "time": "20 minutes",
 "basis": "readme",
 "caveat": "You still need the SAM 2 package installed; the Hub only supplies the weights.",
 "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.8,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/facebookresearch-sam2/load-sam2-from-hugging-face/",
 "md": "https://dedupedai.com/use-cases/facebookresearch-sam2/load-sam2-from-hugging-face/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--load-sam2-from-hugging-face.json",
 "api_version": "v1"
}
