Cut objects out

Click anything in a photo and SAM outlines it with three guesses, or let a background remover find the main subject by itself. Both run in your browser.

IntermediateExplained in Cutting objects out

Cut objects out

SAM outlines whatever you click, offering three guesses. A background remover finds the main subject by itself.

Model
Show
Sample photos

Your photos and camera frames are processed on this device and never uploaded.

Recorded from SAM 2.1 tiny

Loading the model's recorded outputs for the marked points on the eight sample photos.

About the download

Outline anything you click in any picture. This uses SAM 2.1 tiny, a 39-million-parameter segmentation model from Meta (2024) that outlines whatever object you click on.

The first time, your browser downloads about 78 MB of model files from Hugging Face, plus a 14 MB runtime from this site. Both are cached for later visits. Everything runs on your device; no photo or camera frame is sent anywhere.

Manage downloads

Loading the recorded results

SAM 2.1 tiny reads each picture once (the slow part) and then outlines every click in a fraction of a second. BiRefNet lite needs no clicks.

Shown maskn/a
SAM's rating of itn/a
Fills its boxn/a
Timen/a

Challenges

0 of 4 complete

  1. With a single click, get three candidate masks where the largest is at least ten times the size of the smallest. (not yet)
  2. Show a mask that fills less than half of its own bounding box. (not yet)
  3. Find a click where SAM rates even its best mask below 50%. (not yet)
  4. Find a photo where the subject finder keeps nothing at all. (not yet)

Try this

  • On the dog, click the collar, then the head, then the lawn. Compare SAM’s three guesses each time.
  • Show the whole dog and read how much of its own box it fills.
  • Try a pillar in the corridor or the plum branch in the print, and read SAM’s rating of its best mask.
  • Switch to Find the subject and try every sample photo. Which ones come back empty?
Masks, IoU, and a soft cut-outPython with NumPy
import numpy as np

# The true outline of an L-shaped object in a 6 x 8 picture (True = object).
truth = np.zeros((6, 8), dtype=bool)
truth[1:5, 2] = True       # the upright
truth[4, 2:7] = True       # the foot

def iou(a, b):
    """Intersection over union: overlap divided by the area either one covers."""
    return (a & b).sum() / (a | b).sum()

# Two guesses: just the upright, and the whole L plus one stray pixel.
upright = np.zeros_like(truth)
upright[1:5, 2] = True
whole = truth.copy()
whole[0, 7] = True
print(f"upright: IoU {iou(upright, truth):.2f}")
print(f"whole:   IoU {iou(whole, truth):.2f}")  # SAM predicts this number for each guess

# How much of its own bounding box the object fills.
rows, cols = np.nonzero(truth)
box = (rows.max() - rows.min() + 1) * (cols.max() - cols.min() + 1)
print(f"the L fills {truth.sum() / box:.0%} of its box")

# Cutting out with a soft matte: each pixel mixes the photo and a new backdrop.
alpha = np.array([0.0, 0.3, 1.0])   # background, a wisp of hair, subject
photo, backdrop = 200.0, 50.0       # brightness of one photo pixel and the backdrop
print("composite:", alpha * photo + (1 - alpha) * backdrop)
upright: IoU 0.50
whole:   IoU 0.89
the L fills 40% of its box
composite: [ 50.  95. 200.]

Sample photos, all CC0 on Wikimedia Commons: Dog by Joselodos; Cat by Vyshnavi medicharla; Cat on a motorcycle by CAPTAIN RAJU; Breakfast by Andy Li; Street by Mucklagh; Cafe by Andy Li; Corridor by Sindugab; Woodblock print by Utagawa Hiroshige (Metropolitan Museum of Art).

Try "embedding", "softmax", "overfitting", or "backpropagation".