Skip to content
Benchmo
Language: English

Remove the background from an image

Cut the main subject out of a photo and get a transparent PNG, or put it on white or any color.

Background

Processed on your device. Files are not uploaded.

Before the first photo, your browser downloads about 20 MB: the 4.6 MB model that finds the subject and the 14.8 MB engine that runs it. On mobile data, that is worth knowing. It happens once; after that both come from the browser’s cache.

A 600 × 400 photo of a coffee cup on a wooden table took about 5 seconds on a 4-core computer the first time, nearly 2 of them for loading the model, and about 3 seconds for each photo after that. The cup, saucer and spoon came out whole, with the table gone. Switching between Transparent, White and Color afterwards is quick, because the model does not run again; only the background is redrawn.

A coffee cup on a saucer: the original photo on the left, the cut-out on a transparent background on the right

What gives a clean cut-out?

One subject that stands out from what is behind it: a product on a table, a cup, a person against a plain wall, with some space around it. The model rates every pixel from “background” to “subject” and keeps the most eye-catching object, so a group photo or a busy street gives uneven results. Subject and background in similar colors are the hardest case.

Where does it struggle?

Close-ups and fine strands. A close-up of a cat’s face that fills almost the whole frame kept the face and ears, but the whiskers reaching past the outline were cut off, and the fur along the edge came out smoother than it is. Loose hair and lace behave the same way. When an edge is wrong, a second photo with a plainer background usually helps more than anything else.

Transparent, White or Color?

Transparent gives a PNG, for slides, websites, or placing on another picture. White or a color of your choice gives a JPG, which suits shop listings and forms that ask for a plain background. Expect the PNG to be large: the coffee photo, 442 KB as PNG, became 540 KB with transparency.

What kind of model is it?

U²-Net-p, a small neural network for finding the main object in a picture, published by Qin and colleagues in 2020 under the Apache 2.0 license, which allows commercial use. It runs in ONNX Runtime inside your browser. It was chosen because it is small enough to download in a web page; that is also why its edges are softer than those of large models. The original pixels are not changed, only a transparency channel is added; EXIF data is not copied.

Questions and answers

Is my photo uploaded?

No. What travels is the other direction: the first time, your browser downloads the model and the engine that runs it, about 20 MB, and then the work happens on your device. Your photo stays there.

How much data does the first use take?

About 20 MB, once: 4.6 MB for the U²-Net-p model and 14.8 MB for ONNX Runtime, the engine that runs it. Your browser caches both, so the next photos start right away. Nothing is downloaded until you choose an image.

Why are hair, fur and whiskers soft or cut off?

The model sees a 320 × 320 copy of your photo, and its outline is scaled up to the full size. Single hairs and whiskers are thinner than that outline can follow. Smooth-edged objects, such as a cup or a box, come out much cleaner.

Why is the PNG so much bigger than my photo?

A transparent PNG stores every pixel without loss. A 31.6 KB JPG of a cat became a 296 KB PNG. If you do not need transparency, choose White or Color: you get a JPG instead, which is far smaller.

Does it work with iPhone HEIC photos?

Yes. HEIC, AVIF, WebP, PNG and JPG are all accepted. The coffee photo as a 134 KB HEIC gave the same cut-out as the PNG version, with 46% of the pixels kept fully opaque in both.