Who it is forA developer cutting objects out of product photos.
The problemHand masking objects is slow and inconsistent.
The outcomeMasks for the objects you prompted.
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
- Run
git clone https://github.com/facebookresearch/sam2.git && cd sam2thenpip install -e . - Download checkpoints with
./download_ckpts.shinside 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
Prompt for your agent
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>.
Caveat. Install compiles a CUDA extension; if it fails SAM 2 still works with some post-processing limited.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for facebookresearch/sam2 and "Segment an object in an image from a click"
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