Background Removal / Replacement
Strips the background from an image (PNG with alpha channel) or replaces it with another image.
Available models
| Model | Note |
|---|---|
spook-background (recommended) | rembg / U-2-Net derivative, GPU |
Two paths
New alias path (v2.0.0+, preferred)
bash
curl https://app.qevron.ai/v1/vision/background \
-H "Authorization: Bearer sk-..." \
-H "Content-Type: application/json" \
-d '{
"model": "spook-background",
"image": "data:image/jpeg;base64,...",
"mode": "remove"
}'Legacy (custom_test)
bash
curl https://app.qevron.ai/api/channel/86/custom_test \
-H "Authorization: Bearer sk-..." \
-d '{"model": "spook-background", "image": "data:image/jpeg;base64,..."}'Python
python
import base64, requests
with open("product.jpg", "rb") as f:
b64 = base64.b64encode(f.read()).decode()
resp = requests.post(
"https://app.qevron.ai/v1/vision/background",
headers={"Authorization": "Bearer sk-..."},
json={
"model": "spook-background",
"image": f"data:image/jpeg;base64,{b64}",
"mode": "remove",
},
)
out_b64 = resp.json()["image"] # data:image/png;base64,...
payload = out_b64.split(",", 1)[1]
with open("product-transparent.png", "wb") as f:
f.write(base64.b64decode(payload))mode parameter
| Value | Behavior |
|---|---|
remove (default) | Background becomes transparent (PNG + alpha) |
replace | Replaces background — requires background_image (base64) |
Use cases
- E-commerce product photos → product on a clean white background
- Profile photo composites → cut out a person, drop them into a new scene
- Document isolation → take "invoice on a desk" and keep only the invoice
Quality tips
- Sharp subject/background contrast: best results when subject edges are clear. Similar colors confuse the model.
- Resolution: 1024 px is ideal. 4K is slow; 256 px loses detail.
- Hair and translucent objects: glass, water, fine hair — the hardest cases; manual touch-up may be needed.
Troubleshooting
- Part of subject got removed → contrast too low. Try a sharper source image, or
mode=softif available. - Slow → first request triggers GPU warmup (~2–3 s). Subsequent requests are fast.
Next: Image generation · OCR