Skip to contentSkip to the inputSkip to the result

Remove the background

Cut the subject out of a photo

Loading tool

Instructions

Remove the background

How to use

  1. Choose a photo, say whether it shows people or something else, then press Remove background.
  2. Fix anything missed or taken by setting the brush to Keep or Erase and rubbing over the preview.

Supported input

  • JPG, PNG and WebP up to 40 MB.
  • The subject is found on a copy of up to 2,400 px on the long side, and the result is saved as a transparent PNG at the original size.
  • The background can be filled white or black, the edge softened, and the mask corrected with a keep or erase brush, by mouse or finger (the last ten strokes can be undone).
  • Where the browser offers a GPU (WebGPU) the model runs on it, otherwise on the CPU, with the same downloads.

Input example

product.jpg

Result example

A PNG with a transparent background

Troubleshooting

  • If the model cannot be downloaded, check the connection and press again.
  • Older devices and browsers may be slow or unable to run it.

Limitations

  • On first use the model that finds the background is downloaded once from huggingface.co (about 4.4 MB for general pictures, 24.7 MB for people), and the runtime that runs it from cdn.jsdelivr.net (about 27 MB).
  • Those are outside requests; your photo is not sent.
  • Fine detail such as hair, and areas the same colour as the background, may not come out clean; fix them with the brush.

How it works

  • Finds the subject of a photo and makes the background transparent.
  • The work is done on this device; the photo is not uploaded.

Inside background removal: two models, the files it downloads, and how the mask reaches full size

When it helps

  • Swapping the cluttered background of a product photo for plain white before listing it
  • Cutting out a pet or a person as a transparent PNG for a sticker, an avatar or a slide
  • Giving a set of photos the same background colour so a catalogue page looks consistent

Two models for finding the subject

  • Objects, animals, general uses U²-Netp, the small version released with the U²-Net paper (2020). It is trained to find the most prominent object in a picture, and the file is 4,574,861 bytes. The photo is squeezed into a 320 × 320 square regardless of its shape, and the resulting mask is stretched so its lowest value becomes 0 and its highest 255.
  • People uses MODNet (2020), a portrait matting model that grades transparency across fine boundaries such as hair. The file is 25,888,640 bytes. The photo goes in with its short side at 512 px, rounded to a multiple of 32.
  • Both run through Transformers.js on ONNX Runtime Web. Where the browser offers the GPU through WebGPU the model runs there; otherwise it runs on one CPU thread, and a GPU run that fails is retried on the CPU.

What is downloaded, and what is never sent

The first run fetches from two places. From huggingface.co, only config.json, preprocessor_config.json and onnx/model.onnx at a fixed commit of the chosen model; from cdn.jsdelivr.net, the WebAssembly file of onnxruntime-web 1.31.0-dev (26,861,777 bytes). The code refuses any other address, any address with a query string and any request with a body, and sends no cookies.

Your photo is in none of those requests. The work happens in a worker thread inside the browser, and the PNG is made on your device. The downloaded files normally stay in the browser cache, so later runs start faster.

Worked example: the mask for a 4032 × 3024 photo

  1. 1A copy at 2,400 px on the long side (2400 × 1800) goes to the model.
  2. 2The object model returns a 320 × 320 mask, enlarged 7.5 times to 2400 × 1800 for the preview.
  3. 3On saving, the original 4032 × 3024 photo is drawn as it is and the mask, smoothly stretched to that size, supplies only the transparency. Colour and detail are the original pixels.
  4. 4The result is a 4032 × 3024 PNG. iPhone and iPad cap canvases at about 16.7 megapixels, so a 6000 × 4000 photo is saved there at 5017 × 3344 px.

What the edge slider and the brush do

  • The edge slider sets the curve that turns mask values (0–255) into transparency: a smooth rise across 128 ± (100 − slider) × 1.27.
  • At 50 the transition runs from 64.5 to 191.5, so a mask value of 96 becomes opacity 39, 128 becomes 127 and 160 becomes 216. At 100 everything up to 128 is fully transparent and 129 up fully opaque, a hard edge; at 0 the whole range from 0 to 255 is a gentle ramp.
  • The brush paints along the whole path of a stroke and feathers the outer 35% of its radius. Keep only ever raises mask values and Erase only lowers them, so rubbing the same spot repeatedly never mixes the two.

Pictures that come out poorly

  • See-through things such as glass, plastic film and smoke may keep the background showing through them, or vanish entirely.
  • A shadow under an object may be kept as part of it or removed with the background. Check a product’s floor shadow and tidy it with the brush.
  • Several subjects, or one very small one, leave the model unsure what to keep. Crop to the subject first for a better result.
  • A run that has not finished after three minutes is stopped, with a suggestion to try a smaller picture.

Checked

Frequently asked questions

Is my photo uploaded to remove the background?

No, the work runs on this device. On first use only, the model is downloaded from huggingface.co (about 4.4 MB general, 24.7 MB for people) and the runtime file from cdn.jsdelivr.net; your photo is not sent.

Should I choose People or the general option?

For portraits, choose People to use a model made for human outlines. For products, animals and everything else, Objects, animals, general works better.

Is the result saved at the original size?

Yes. The subject is found on a copy reduced to 2,400 px on the long side, but the outline is stretched back over the original when saving, so a 4000×3000 photo is saved as a 4000×3000 PNG. Fill the background with white for an ID-photo look.

Some hair or background came out wrong.

After removing the background, set Fix with a brush to Keep and rub over what was cut off to bring it back, or to Erase and rub over leftover background. The brush size can be changed, a finger works too, and Undo takes back the last ten strokes. The fixes go into the saved PNG.