Five posts in this series have measured cutout edges with checks that need no reference foreground: edge geometry, colour contamination, the edge-hue test, its blind spot, and a coverage matrix scoring all of them against known failures. Every one of those used variants I built by hand from one matte.

This post points the same checks at something I didn't build: seven of rembg's local models, run on the same photo, through the same call.

Two things came out of it that I did not expect. The first is that the masks are practically the same mask — the models disagree about the edge and almost nothing else. The second is that the default output is premultiplied, so if you take what remove() returns and put it on a white page, the edge comes out about 22 L* too dark, and nothing in the file tells you that happened.

The setup

One image, unchanged from the rest of the series: a 1200×800 Unsplash photo of a white ceramic mug, and an Apple Vision matte (VNGenerateForegroundInstanceMaskRequest) as my reference for where the silhouette actually is. That matte has 9,959 partial-band pixels and a 4.05 px wide alpha ramp.

Seven models, all local, all through the same call:

from rembg import new_session, remove from PIL import Image session = new_session("birefnet-general-lite") out = remove(Image.open("mug.jpg"), session=session, alpha_matting=False, post_process_mask=False) 

rembg 2.0.87, onnxruntime on CPU, macOS arm64. Timings below are inference only, minimum of three runs after a warm-up, model already loaded. Weights run from 4.4 MB (u2netp) to 977 MB (bria-rmbg) on disk.

This photo is a deliberately awkward subject for half of these checks and a good one for the other half. The mug's body sits at C* 2.0 — essentially neutral — on a background at RGB (218, 218, 218) against a body at (217, 217, 213). There is almost no colour difference anywhere in the frame, so any colour check is close to its noise floor. The geometry, on the other hand, is a clean vertical silhouette edge with nothing behind it, which is why the band-width numbers below are stable to two decimals.

The masks agree

I compared all 21 pairs of models by Dice on the alpha >= 128 masks, and by Pearson correlation on the raw alpha.

check result
Dice, all 21 pairs 0.9880 – 0.9977
Pearson r on raw alpha 0.9945 – 0.9995
Closest pair birefnet-general-lite / birefnet-general, 0.9977
Furthest pair u2net / bria-rmbg, 0.9880

Nothing here separates the models. On this photo, every one of them finds the mug, and finds the same mug. If your problem is "the model picked the wrong object", switching models inside this list is not the lever — this is a salient object on a plain background, which is the easy case for all of them.

The edges do not agree

The edge is where they part. Same check as always: band = pixels with 5 < alpha < 250, band width = twice the mean distance from a band pixel to the nearest non-band pixel.

model band width partial px edge C* Δhue chroma resid inference
u2netp 8.29 px 16,469 1.53 −8.1° +0.44 0.07 s
silueta 5.19 px 14,329 1.51 −8.4° +0.50 0.14 s
u2net 4.39 px 11,104 1.29 −11.7° +0.26 0.27 s
isnet-general-use 3.53 px 7,442 1.21 −9.7° +0.22 0.66 s
birefnet-general-lite 2.33 px 3,852 1.15 −13.3° +0.08 3.69 s
birefnet-general 2.43 px 4,310 1.23 −11.3° +0.16 5.94 s
bria-rmbg (default) 2.66 px 5,066 1.56 −10.2° +0.48 6.02 s

A 3.6x spread in band width, and 4.3x in the number of partially transparent pixels. u2netp leaves sixteen thousand pixels asking you what they are; birefnet-general-lite leaves three thousand eight hundred. Against my Vision reference at 4.05 px, the field lands from 1.7x below that reference to 2x above it.

The left silhouette edge of a white mug at 5x, cut by seven rembg models and composed on a dark background

The left silhouette edge at 5x, each panel composed from the untouched source pixels and that model's own alpha. The shapes are the same shape. The ramps are not.

The colour columns are quiet, and it took me a while to be honest about why. Every model lands under the thresholds from earlier posts — C* between 1.15 and 1.56 against a limit of 10°, chroma residual under +0.5 against a limit of 2.0. That is not evidence that these models are clean. On a neutral mug against a neutral grey background there is nothing to bleed, so the checks are measuring their own noise floor. The Δhue values are all negative and clustered between −8° and −13°, which is what a hue comparison looks like when the body has too little chroma to define a hue in the first place.

To ask the colour question properly you need a background that can contaminate. More on that below.

Speed is not the dial you think it is

The README is upfront that bria-rmbg "runs at 1024x1024, so it is slower than u2net; pass -m u2net for a smaller, faster model with blockier edges". The data agrees with the speed half of that, and the band width agrees with "blockier" too: u2net is 4.39 px against the default's 2.66 px.

But the trade isn't a single dial. birefnet-general-lite has the narrowest band of the seven (2.33 px) and runs in 3.69 s. birefnet-general has a wider band (2.43 px) and takes 5.94 s — 1.6x the time for a slightly worse edge. The default sits behind both on width while being the slowest thing in the table. Whatever birefnet-general spends its extra two seconds on, it is not this edge.

So the honest summary for a product-photo pipeline is: pick the narrowest band you can afford, and don't assume the default is the quality end of the range. It isn't, on this image.

The output is premultiplied

Now the part I didn't go looking for. I was computing L* residuals — the same trick as the chroma residual, but on lightness — and every model came back 14 L* darker than the geometry allowed. Seven for seven, which is not a model property. It's a library property.

Here is the default path in rembg/bg.py:

def naive_cutout(img, mask): empty = Image.new("RGBA", (img.size), 0) cutout = Image.composite(img, empty, mask) return cutout 

Image.composite isn't "keep these pixels, drop those". It interpolates every channel by the mask, including the colour channels, against a transparent black. The result is rgb * alpha with alpha in the fourth channel: a premultiplied pixel.

I checked it the blunt way, by asking which of two numbers the stored colour is closer to, on the partial-alpha pixels only:

model mean |stored − source| mean |stored − source·alpha|
u2netp 90.78 0.25
silueta 96.54 0.25
u2net 98.44 0.25
isnet-general-use 103.33 0.25
birefnet-general-lite 97.06 0.25
birefnet-general 97.51 0.24
bria-rmbg 92.00 0.25

A quarter of one level of error. Every model, every time.

The problem is that PNG has no premultiplied flag. A PNG pixel is straight alpha by definition, and every consumer you will hand this file to — PIL's Image.alpha_composite, CSS, ImageMagick, Cairo, a canvas in a browser — multiplies by alpha again. Composited on white, a pixel at half coverage lands at rgb * 0.25 + 255 * 0.75 instead of rgb * 0.5 + 255 * 0.5.

The same edge composited on white from the default rembg output and from putalpha=True, with a chart of composited L* against alpha

Same crop, same alpha channel to the last byte, two ways of reading the RGB. The upper panel is what remove() returns by default.

Measured on the default model, over the band:

path L* residual at half coverage band pixels off by more than 5 L*
default output −13.7 −21.7 81%
putalpha=True −4.6 −4.6 48%

The −4.6 baseline is my measurement, not the library: the expectation model uses the mean lightness of the eroded opaque core on a mug that is shaded from top to bottom, so even a perfect cutout reads a few L* off in the band. The signal is the gap between the two rows, about 17 L* at half coverage, and it is entirely a difference in how the returned RGB is meant to be read.

It gets worse if you use the library's own convenience parameter. remove(..., bgcolor=(255, 255, 255, 255)) is documented as "apply a background colour", and it composites with Image.alpha_composite — which assumes straight alpha. So it takes the premultiplied pixels and multiplies them by alpha a second time. Measured on the same crop, the band mean comes out at 197.2 instead of 223.1, and at half coverage the error is 47.6 levels out of 255. The convenience path is the one that fails hardest.

Two ways out, and one of them isn't in the docs

The same module contains a second cutout function:

def putalpha_cutout(img, mask): cutout = img.copy() cutout.putalpha(mask) return cutout 

That one keeps your RGB and only attaches alpha. Straight alpha, correct by construction, and the alpha channel is byte-identical to the default path's. The switch is putalpha=True, which reaches it through **kwargs:

out = remove(img, session=session, putalpha=True) 

As far as I can tell, putalpha appears in rembg's README exactly once — in the list of keys extras will accept — with no explanation of what it changes. The colour decontamination mode (decontaminate=True, CLI -dc) also returns straight alpha, and is documented properly.

If you already have premultiplied cutouts sitting on disk, the fix is one division — rgb / (alpha / 255) — and you lose almost nothing. I checked: run the default output and the putalpha output through the same un-premultiply and they agree to a mean of 0.4 RGB levels across the band, worst pixel 2.1 — that is 8-bit rounding of the product, not lost data. The information is all there. What's missing is any signal in the file that tells you to do it.

There is a second-order lesson for this series: every colour check I've published needs straight alpha. Feed one of these default cutouts to those checks and you are measuring a darker image than the one you think you have. My first pass at the table above did exactly that, which is why the numbers in it come from a putalpha=True re-run.

Neither path removes a blend

Straight alpha fixes the pixel's brightness. It does not fix what the pixel contains. A soft edge pixel is still alpha·F + (1−alpha)·G, and putalpha hands you that blend untouched. That is what -dc is for, and this series has the instrument to test it — but the white mug on grey paper can't say anything about it, because there is nothing to contaminate.

So I built the case where the answer is known. Take the same photo and the same Vision matte, and composite the mug onto a saturated green backdrop, RGB (58, 138, 74), using the matte as the blend weight. Every edge pixel is now exactly alpha·F + (1−alpha)·G with F known — the original photo — so any output can be scored against the true foreground colour, not against a proxy.

Run the three output paths on that composite and recover the foreground colour (rgb / alpha where the pixel is premultiplied, rgb where it isn't), then score it two ways: mean distance from the true F in RGB levels, and green excess, G − (R+B)/2, which is what a green cast is.

bria-rmbg fg error green excess visible error on white
true foreground 0 +1.2 0
default / putalpha 31.5 +20.8 18.0
decontaminate=True 13.5 +1.7 7.7
u2net fg error green excess visible error on white
true foreground 0 +1.2 0
default / putalpha 67.6 +42.1 39.0
decontaminate=True 33.2 +17.8 20.2

-dc does what it says on the default model: green excess falls from +20.8 to +1.7, which is the mug's own +1.2 within measurement noise, and the visible error on a white page drops by 57%.

It does it less well on u2net, and the reason is instructive. Decontamination inverts the blend using the alpha the model predicted. When that alpha is the 8.29 px ramp from the table at the top instead of the matte's 4.05 px, the inversion is dividing by the wrong coverage, and the colour comes back only part way — green excess stops at +17.8. The mask quality sets a ceiling on how much colour you can recover, which is a good argument for using -dc with a model that gets the edge right rather than with the fastest one available.

What I'd do with this

  • Choose by band width, not by speed. birefnet-general-lite is the best edge in the table and 1.6x faster than the model with a wider one. The default is neither the fastest nor the sharpest.
  • Never hand remove()'s default output to a compositor. Either pass putalpha=True or decontaminate=True, or un-premultiply before you composite. If you've been seeing grey fringing on white backgrounds and blaming the model, check the pixel values first: out[..., :3] / (out[..., 3:] / 255) should give you back your original colours.
  • If the subject was shot on something coloured, use -dc. It's cheap, it works, and the only thing it needs from you is a mask that's roughly right.
  • Pass -m explicitly if you ship commercially. The default is bria-rmbg, and the README is clear that RMBG-2.0's weights need a paid agreement for commercial use — in a bullet at the end of the model list, which is easy to scroll past, and nothing at runtime repeats it.

What this doesn't cover

One photo, one object, one machine. No hair, no fur, no motion blur, no transparency — the cases where the edge actually gets hard and where -a and -vm exist for a reason. CPU inference only, so the ranking of the slow models would move on a GPU. And the Vision matte is another model's opinion, not ground truth; it's a 4.05 px reference, not the line a human would draw.

The green-backdrop test is a simulation, not a shoot: a synthetic blend has no lens blur, no sensor noise and no light bouncing off the backdrop onto the product. It tests the inversion arithmetic exactly, which is what I wanted, and says nothing about a photographer's worst case.

The premultiplied output is a code path, not a measured corpus — I read naive_cutout and checked the arithmetic on seven models and one image. If someone has a batch of real cutouts where this mattered, or didn't, I'd like to know which.

I work on PicViva, an editor whose background removal runs over seller photos, and the reason this post exists at all is that the premultiplied edge was showing up as a dirty halo on white product pages — a complaint I had been attributing to the models for longer than I'd like to admit. It was the compositor multiplying twice.

If you've hit this one: did you find it from the numbers, or from staring at a halo that shouldn't be there?