Smart Brush

Fix a cutout with two brushes. Paint Keep over what went missing and Remove over what should go. Available in the Pro Model API, Pro Model Self-Host and the open weights.

How it works#

Missed a strand, or kept a chair you did not want? Mark it. The image is matted, then your strokes edit that matte.

  • One stroke on an object is enough: it reaches the whole object.
  • A rough stroke is fine; the edges are refined again.
  • Add more strokes and run again until it is right.
  • Where Keep and Remove overlap, Remove wins.

Masks are grayscale images at the photo's size, white where you painted. Send at least one.

Pro Model API#

Send keep_mask / remove_mask with the image on the background removal and alpha matte endpoints (keep_mask_base64 / remove_mask_base64 on the base64 ones). 1 credit per request. To fix a result further, send all strokes so far again. Try it without code in the Smart Brush editor or the live demo.

Pro Model API

curl -X POST \
  -H "X-API-Key: $WITHOUTBG_API_KEY" \
  -F "file=@photo.jpg" \
  -F "keep_mask=@keep.png" \
  -F "remove_mask=@remove.png" \
  --output fixed.png \
  "https://api.withoutbg.com/v1.0/image-without-background"

Pro Model Self-Host#

The same Keep / Remove edit on your own CPU servers: send keep_mask, remove_mask and, to refine in rounds, the previous matte to /v1/remove-background. Images never leave your infrastructure. See Pro Model Self-Host.

Open weights#

New in Open Weights v4: a small stroke-edit network (2.5 MB, Apache 2.0 like the rest) runs on your machine. Pixels away from your strokes do not change. On our frozen validation set, one round of strokes cuts the error inside the edited region by 83% on matte fixes and 96% on unwanted or missing objects.

Python

from withoutbg import WithoutBG

model = WithoutBG.open_weights()
result = model.remove_background("photo.jpg")

# Masks: white = painted, same size as the photo
fixed = model.edit("photo.jpg", keep="keep.png", remove="remove.png", matte=result)
fixed.save("fixed.png")

Docker / Local API

curl -X POST http://localhost:8000/v1/remove-background \
  -F image=@photo.jpg \
  -F keep_mask=@keep.png \
  -F remove_mask=@remove.png \
  -o fixed.png