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
- 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
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
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer