DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to load SAM 2 from Hugging Face without the checkpoint script with Sam2

Use from_pretrained to pull facebook/sam2-hiera-large straight from the Hub.

Short answer: Install SAM 2 with pip install -e . from the cloned repo; then install the Hub client with pip install huggingface_hub; call SAM2ImagePredictor.from_pretrained("facebook/sam2-hiera-large") or SAM2VideoPredictor.from_pretrained. All steps.

  • Research
  • Beginner
  • 20 minutes
  • From the README
  • Claude Code
  • Codex
  • Cursor
  • Gemini CLI

Who it is forA developer prototyping in a notebook who wants the shortest path.

The problemManaging checkpoint files by hand is friction for a quick test.

The outcomeA working image or video predictor loaded from the Hub.

What you need first

  • 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

Steps

  1. Install SAM 2 with pip install -e . from the cloned repo
  2. Install the Hub client with pip install huggingface_hub
  3. Call SAM2ImagePredictor.from_pretrained("facebook/sam2-hiera-large") or SAM2VideoPredictor.from_pretrained
  4. Run set_image and predict as usual

Prompt for your agent

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>.

Caveat. You still need the SAM 2 package installed; the Hub only supplies the weights.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for facebookresearch/sam2 and "Load SAM 2 from Hugging Face without the checkpoint script"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer