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

How to segment an object in an image from a click with Sam2

Install SAM 2, download checkpoints and get masks for an image from point or box prompts.

Short answer: Run git clone https://github.com/facebookresearch/sam2.git && cd sam2 then pip install -e; then 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. All steps.

  • Top pick
  • Research
  • Intermediate
  • 45 minutes
  • From the README
  • Claude Code
  • Codex
  • Cursor
  • Gemini CLI

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

  1. Run git clone https://github.com/facebookresearch/sam2.git && cd sam2 then pip install -e .
  2. Download checkpoints with ./download_ckpts.sh inside the checkpoints folder
  3. Build a SAM2ImagePredictor from configs/sam2.1/sam2.1_hiera_l.yaml and ./checkpoints/sam2.1_hiera_large.pt
  4. 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

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