You need to remove backgrounds from images. rembg has 17,000+ GitHub stars and works with pip install. But once you test on real photos with complex backgrounds, hair, or transparent objects, the gaps appear.
We tested rembg, transparent-background, and a cloud API on the same portrait photo — a woman with detailed hair and a complex foliage background. Here's what happened.
Quick Comparison
| Criteria | rembg | transparent-background | Cloud API |
|---|---|---|---|
| Setup | pip install rembg[cpu] | pip install transparent-background | API key (2 min) |
| Dependencies | ONNX Runtime (~400 MB) | PyTorch (~1.8 GB) | Any HTTP client |
| Speed (CPU) | ~10s/image | ~16s + 28s model load | ~3.5s (incl. network) |
| Hair detail | White halos, lost strands | Better edges but residual bg | Clean edges, strands preserved |
| Offline | Yes | Yes | No |
| Cost | Free + compute | Free + compute | Free 100/mo, then $12.99/mo |
Real Test Results
On a portrait with detailed hair against foliage:
rembg — Visible white halos around hair. Top of head partially cut off. Flower and leaves roughly segmented. 10.0s on CPU.
transparent-background — Better edge detection but residual background still visible around hair. 16.5s on CPU (+ 28s model load).
Cloud API — Cleanest result. Hair strands preserved without halos. Smooth, production-ready edges. 3.5s including network round-trip.
Code: Test Both Yourself
import requests, time
from rembg import remove
from PIL import Image
image_path = "test_photo.jpg"
img = Image.open(image_path)
# --- rembg ---
t0 = time.time()
rembg_result = remove(img)
print(f"rembg: {time.time() - t0:.1f}s")
rembg_result.save("rembg_output.png")
# --- Cloud API ---
t0 = time.time()
with open(image_path, "rb") as f:
resp = requests.post(
"https://background-removal-ai.p.rapidapi.com/remove-background",
headers={
"x-rapidapi-host": "background-removal-ai.p.rapidapi.com",
"x-rapidapi-key": "YOUR_API_KEY",
},
files={"image": f},
)
data = resp.json()
print(f"API: {time.time() - t0:.1f}s")
print(f"Result: {data['image_url']}")
When Open-Source Is Enough
rembg works fine when you:
- Work offline or in air-gapped environments
- Process images with simple backgrounds (studio photos, solid colors)
- Need custom pipeline control — modify the mask, integrate into ML workflows
- Have existing GPU infrastructure for millions of images
When a Cloud API Wins
- Production quality — e-commerce, profile photos, marketing assets
- No GPU — 3x faster than rembg on CPU, 12x faster than transparent-background
- Lightweight deployments — no PyTorch in your Lambda/container
- Custom background replacement — single API call vs manual compositing
- Zero maintenance — no model updates or dependency conflicts
Pricing
| Plan | Price | Requests/mo | Per image |
|---|---|---|---|
| Basic | Free | 100 | $0 |
| Pro | $12.99/mo | 10,000 | ~$0.0013 |
| Ultra | $49.99/mo | 50,000 | ~$0.001 |
rembg is "free" but GPU instances cost $50–365/month. On CPU, 10s/image = ~360 images/hour max throughput.
Bottom Line
Both tools have their place. Use rembg for offline, simple backgrounds, or custom ML pipelines. Use a cloud API when quality, speed, and simplicity matter in production.
The AI Engine Background Removal API offers 100 free requests/month.
👉 Read the full guide with JavaScript examples, visual comparison, and detailed benchmarks
Top comments (0)