Skip to content
BgReplacer

How BgReplacer works

Four steps, all inside your browser: find the subject, cut it out, draw a background, and make the two agree.

1. Portrait or object?

When you add a photo in Auto mode, a face detector called YuNet (230 KB) looks for faces. If it finds one that takes up a reasonable share of the frame, the photo is treated as a portrait. If not, it’s treated as an object: a product, a pet, a plate of food, a car.

2. The cutout

Portraits go to a portrait matting network (25.9 MB). It reads the photo at a 512-pixel short edge, keeping the photo’s shape, and returns a soft matte, so hair and sheer fabric come back partly transparent instead of chopped. Everything else goes to a general salient-object network (88.1 MB) that works at 1024 × 1024 and returns crisp outlines. A smaller quick people model (6.2 MB) is offered for slow connections. Flat logos and signatures use a colour key instead: it measures every pixel’s distance from the backdrop colour in CIELAB and needs no model at all.

The models run with ONNX Runtime Web: on your graphics card through WebGPU when the browser offers it, otherwise on the processor through WebAssembly. They download once, only after you agree, from our model file server, and are then kept in your browser’s cache storage. You can remove them at any time with “Remove downloaded models” in the studio.

3. Backgrounds as recipes

The 103 backgrounds are drawn by code at whatever size is needed: a 112-pixel tile, the live preview, or a 4096-pixel export. Studio sweeps combine a wall-to-floor gradient, a key light and a vignette. Bokeh, lights and confetti scatter shapes with a seeded random generator, so they look identical at every size. Blur backgrounds start from a clean plate: the subject’s area is filled in from its surroundings first, so no ghost of the subject smears into the blur.

4. Harmonize

  • Match colours compares the subject and the background in CIELAB. It moves the subject’s lightness level and contrast toward the background’s (within limits that protect skin) and shifts its colour cast part of the way toward the scene’s. The mapping is baked into a 33 × 33 × 33 lookup table, so it applies instantly.
  • Light wrap lets a blurred copy of the new background bleed into the subject’s inner edge, the way light from a bright scene wraps around a real object.
  • Shadows are built from the subject’s own matte: a contact shadow squashed flat under its lowest point, or an offset drop shadow.
  • Edge clean estimates the subject’s true colour from nearby solid pixels and uses it to replace the old background’s tint in semi-transparent edges.

Exports

Exports are composed again from scratch at the chosen size. The subject is cleaned at the export resolution, the background is drawn at that size, and the frame is chosen per preset: cover-cropped around the subject for social sizes, product scaled to about 85% of a square, or a face-centred crop for passport-style sizes. JPG and WebP can search for the best quality under a KB limit. The bulk tool builds its ZIP in memory on your device.

Read the privacy page for exactly what network requests the site makes.