How AI background removal works in your browser
By Altaf Ahmed. Written on . Posted in Tutorials.
Removing a background used to mean tracing an outline by hand in Photoshop. Now a neural network can do it in seconds, and it can do it inside your browser tab, without your photo ever leaving your device. Here is how our Background Remover works.
Step 1: The model is downloaded once
The tool uses RMBG-1.4, an image-segmentation model from BRIA AI trained specifically to separate a foreground subject from its background. The first time you use the tool, your browser downloads the model (about 45 MB) and caches it. After that it loads straight from the cache, so later uses start almost immediately.
The model runs with Transformers.js, a library that executes machine-learning models in the browser using WebAssembly. That's what makes local processing possible: the computation happens on your device's processor instead of on a server.
Step 2: Your photo is prepared for the model
The model expects a fixed input, so your image is resized to 1024×1024 pixels and its colour values are normalised. This copy is only used for the analysis; your original stays at full resolution.
Step 3: The model predicts a mask
For every pixel, the model outputs a value between "definitely background" and "definitely subject". Together these values form a mask, a greyscale image where white is the subject, black is the background, and the soft grey values in between are the edges, such as wisps of hair.
Step 4: The mask becomes transparency
The mask is scaled back up to your photo's original size and applied as its alpha (transparency) channel. Pixels the model marked as background become transparent; edge pixels become partly transparent, which is why good cut-outs have soft rather than jagged outlines.
From there you can download a transparent PNG, or place the subject on a solid colour or a background image of your own.
Tips for cleaner results
- Clear subjects work best. A person, product or animal that stands out from the background gives the model the least to guess about.
- Contrast helps. A dark jacket against a dark wall is harder to separate than the same jacket against a bright sky.
- Hair and fur are the hardest part. Expect fine strands to be softened rather than cut out one by one.
- Shadows count as background. If you want a shadow under a product, add it back in your editor after removing the background.
- Crop close to the subject first. The model analyses a 1024×1024 copy of your image, so the more of the frame your subject fills, the more detail the model sees at its edges.
Why local processing matters
Most online background removers upload your photo to their servers. That's a problem for passport photos, ID documents, pictures of children and unreleased product shots. Running the model in your browser means the photo is never transmitted. The only download is the model itself, on first use.
Once you have your cut-out, you can crop it into a circle, turn it into a profile photo, or add a border.