How to use it
- Drop a JPG, PNG, WebP, BMP, GIF or AVIF photo (up to 40 MB).
- Optionally tick “Fill with a solid colour” and pick the colour; you can change this after the run without recomputing.
- Press Remove background. The first run shows the model download progress, then the inference notice.
- Drag the slider to compare, then download the PNG.
Example
A 3,024 × 4,032 px portrait from a phone (2.8 MB JPEG) is processed at 3,072 × 4,096 px. On a 2023 laptop the first run spends about 10–20 s downloading 25.9 MB, then roughly 4–8 s of inference; the result is a 6–9 MB transparent PNG where about 45 % of the pixels are kept as subject. A second photo skips the download entirely.
How the background is removed
The tool loads @huggingface/transformers on demand and builds an image-segmentation pipeline for Xenova/modnet, the ONNX export of MODNet (Ke et al., AAAI 2022: “MODNet: Real-Time Trimap-Free Portrait Matting via Objective Decomposition”). The network is run by ONNX Runtime Web in single-threaded WebAssembly with the full-precision (fp32) weights; the WASM binaries are fetched from jsdelivr pinned to the exact onnxruntime-web version bundled with transformers.js. MODNet infers at 512 px internally and returns one soft foreground matte, which the tool resizes back to the working resolution and writes into the alpha channel of the (EXIF-oriented) pixels; the solid-colour option composites fg × α + colour × (1 − α) instead.
Limits: the model was trained on portraits, so animals, products and landscapes are hit-and-miss; there is no manual refinement brush; fine detail is bounded by the 512 px inference grid; very large photos are downscaled to 4,096 px; inference needs a few hundred MB of memory and may fail on old phones. Nothing is uploaded, but the model and runtime downloads require a connection on first use.
Sources: MODNet paper and code (ZHKKKe/MODNet, MIT), Xenova/modnet model card on Hugging Face, transformers.js documentation (pipelines, env, caching), ONNX Runtime Web.
Questions
- Is the photo uploaded to a server?
- No. The neural network runs inside your browser. The only downloads are the model from huggingface.co and the ONNX Runtime from jsdelivr on first use; your image data never leaves the page.
- Why are the edges soft or slightly haloed?
- MODNet produces a matte, not a binary mask: edge pixels get partial transparency so hair and fuzzy outlines blend naturally. Against a strongly coloured background the blend can carry a tint; placing the cut-out on a similar colour or using the solid-colour option hides it.
- Does it work on products, logos or pets?
- Sometimes. The model is trained on people, so clearly separated objects on plain backgrounds usually work, while thin or transparent items, fur and cluttered scenes often do not. Check the before/after slider before downloading.
- What resolution does the result have?
- The same as the source up to 4,096 px on the longest side; larger photos are downscaled first (the Photo panel says so). The mask itself is computed at 512 px and upscaled, which is why very fine detail stays soft.