AI-powered background removal with local and cloud options
Remove backgrounds from images instantly with AI. Choose between local processing (free) or withoutBG Pro (best quality).
# Install and run in one go
pip install withoutbg
# Remove background from your first image
python -c "from withoutbg import WithoutBG; WithoutBG.opensource().remove_background('your-photo.jpg').save('result.png')"That's it! Your photo now has a transparent background. β¨
Processing 1-10 images occasionally? β withoutBG Pro (zero setup, best quality)
Processing 100+ images? β Local model (free, reusable)
Need offline processing? β Local model
Want best possible quality? β withoutBG Pro
Building commercial product? β withoutBG Pro (scalable)
Need fastest processing? β withoutBG Pro (optimized infrastructure)
View Complete Dockerized Web App Documentation β
docker run -p 80:80 withoutbg/app:latest
# Open in browser
open http://localhostβ Multi-platform support: Works on Intel/AMD (amd64) and ARM (arm64) architectures
View Complete Python SDK Documentation β
# Install (using uv - recommended)
uv add withoutbg
# Or with pip
pip install withoutbgLocal Processing (Free):
from withoutbg import WithoutBG
# Initialize model once, reuse for multiple images (efficient!)
model = WithoutBG.opensource()
result = model.remove_background("input.jpg") # Returns PIL Image.Image
result.save("output.png")
# Standard PIL operations work!
result.show() # View instantly
result.resize((500, 500)) # Resize
result.save("output.webp", quality=95) # Different formatwithoutBG Pro (Best Quality):
from withoutbg import WithoutBG
# Get your API key from withoutbg.com
model = WithoutBG.api(api_key="sk_your_key")
result = model.remove_background("input.jpg")
result.save("output.png")
# Or set environment variable (recommended)
# export WITHOUTBG_API_KEY=sk_your_key
model = WithoutBG.api(api_key="sk_your_key")CLI:
# Process single image
withoutbg photo.jpg
# Process entire photo album
withoutbg ~/Photos/vacation/ --batch --output-dir ~/Photos/vacation-no-bg/
# Convert to JPEG with white background (for printing)
withoutbg portrait.jpg --format jpg --quality 95
# Use withoutBG Pro for best quality
export WITHOUTBG_API_KEY=sk_your_key
withoutbg wedding-photo.jpg --use-api
# Process and watch progress
withoutbg photo.jpg --verboseDon't have
uvyet? It's a fast, modern Python package installer - get it at astral.sh/uv
See More Focus Model Results β
We are finalizing a new architecture designed to deliver superior accuracy and finer detail. Star the repo to bookmark this upgrade for your future toolkit β.
This is a monorepo containing multiple components:
withoutbg/
βββ packages/ # Reusable packages
β βββ python/ # Core Python SDK (published to PyPI)
β
βββ apps/ # End-user applications
β βββ web/ # Web application (React + FastAPI)
β
βββ integrations/ # Third-party tool integrations
β βββ (future: GIMP, Photoshop, Figma plugins)
β
βββ models/ # Shared ML model files
β βββ checkpoints/ # ONNX model files
β
βββ docs/ # Documentation
βββ scripts/ # Development scripts
π Python SDK
Core library for background removal. Published to PyPI.
- Install:
uv add withoutbg(orpip install withoutbg) - Use: Python API + CLI
- Models: Focus v1.0.0 (local), withoutBG Pro
π Web Application
Modern web interface with drag-and-drop UI.
- Stack: React 18 + FastAPI + Nginx
- Deploy: Docker Compose
- Features: Batch processing, live preview
Plugins for popular creative tools.
- GIMP plugin
- Photoshop extension
- Figma plugin
- Blender addon
- β¨ Local Processing: Free, private, offline with Focus v1.0.0
- π withoutBG Pro: Best quality, scalable, 99.9% uptime
- π¦ Batch Processing: Process multiple images efficiently
- π Web Interface: Beautiful drag-and-drop UI
- π§ CLI Tool: Command-line automation
- π¨ Integrations: Work in your favorite tools
All methods return PIL Image objects with transparent backgrounds (RGBA mode):
from withoutbg import WithoutBG
model = WithoutBG.opensource()
result = model.remove_background("photo.jpg") # Returns PIL Image.Image
# Save in different formats
result.save("output.png") # PNG with transparency
result.save("output.webp") # WebP with transparency
result.save("output.jpg", quality=95) # JPEG (no transparency)JPEG Files Don't Support Transparency:
# β This loses transparency (JPEG doesn't support alpha):
result.save("output.jpg")
# β
Use PNG or WebP for transparency:
result.save("output.png") # Keeps alpha channel
result.save("output.webp") # Also works!Model Downloads Happen on First Run:
# First run: ~5-10 seconds (downloading ~320MB of models from HuggingFace)
model = WithoutBG.opensource() # Downloads models to cache
# Second run: Instant! (models cached locally)
model = WithoutBG.opensource() # Uses cache
result = model.remove_background("photo.jpg") # Now processes in ~2-5sOutput File Naming:
- Single file:
photo.jpgβphoto-withoutbg.png - Batch: Creates
photo1-withoutbg.png,photo2-withoutbg.png, etc. - Custom: Use
--outputor--output-dirto specify
from withoutbg import WithoutBG
# Initialize model once - loaded into memory
model = WithoutBG.opensource()
# Process multiple images - model is reused (much faster!)
images = ["photo1.jpg", "photo2.jpg", "photo3.jpg"]
results = model.remove_background_batch(images, output_dir="results/")
# Returns list of PIL Image objectsdef show_progress(progress):
print(f"Processing: {progress * 100:.0f}%")
model = WithoutBG.opensource()
result = model.remove_background("photo.jpg", progress_callback=show_progress)from withoutbg import WithoutBG, APIError, WithoutBGError
try:
model = WithoutBG.api(api_key="sk_your_key")
result = model.remove_background("photo.jpg")
result.save("output.png")
except APIError as e:
print(f"API error: {e}")
except WithoutBGError as e:
print(f"Processing error: {e}")| Metric | Local (CPU) | withoutBG Pro |
|---|---|---|
| First Run | 5-10s (~320MB download) | 1-3s |
| Per Image | 2-5s | 1-3s |
| Memory | ~2GB RAM | None |
| Disk Space | 320MB (one-time) | None |
| Setup | One-time download | API key only |
| Cost | Free forever | Pay per use |
Model Files (cached after first download):
- ISNet segmentation: 177 MB
- Depth Anything V2: 99 MB
- Focus Matting: 27 MB
- Focus Refiner: 15 MB
- Total: ~320 MB (one-time download, cached locally)
π‘ Pro Tip: For batch processing, initialize the model once and reuse it - this is 10-100x faster than reinitializing for each image!
Model download fails?
- Check your internet connection
- Models are downloaded from HuggingFace on first run (~320MB total)
- Or use local model files (see Configuration)
Out of memory?
- Try processing smaller images or use withoutBG Pro
- Reduce batch size when processing multiple images
Import errors or "module not found"?
# Make sure you're in the right environment
which python # Check your Python path
pip list | grep withoutbg # Verify installation
# If using virtual environment
source venv/bin/activate # Activate first
pip install withoutbg # Then installAPI key invalid?
- Get your API key from withoutbg.com
- Set environment variable:
export WITHOUTBG_API_KEY=sk_your_key
Slow processing on first run?
- Normal! Models are being downloaded (~320MB)
- Subsequent runs will be much faster (~2-5s per image)
- Python SDK Docs - Complete API reference and examples
- Python SDK Documentation - Online documentation
- Web App Docs - Deployment and development guide
- Dockerized Web App Documentation - Online documentation
- withoutBG Pro API Results - See example outputs
- Focus Model Results - See example outputs
- Compare Focus vs Pro - Model comparison
cd packages/python
# Install in development mode (using uv - recommended)
uv sync --extra dev
# Or with pip
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black src/ tests/
ruff check src/ tests/# Development mode (hot-reload)
docker-compose -f apps/web/docker-compose.yml up
# Or run components separately
cd apps/web/backend
uv sync
uvicorn app.main:app --reload
cd apps/web/frontend
npm install
npm run devOur most advanced open source model with:
- β Significantly better edge detail - Crisp, clean edges
- β Superior hair/fur handling - Natural-looking fine details
- β Better generalization - Works on diverse image types
See example outputs above and check sample-results/ for more visual comparisons.
Apache License 2.0 - see LICENSE
- Depth Anything V2: Apache 2.0 License (only vits model)
- ISNet: Apache 2.0 License
- segmentation-models-pytorch: MIT License (used to train matting/refiner models)
See THIRD_PARTY_LICENSES.md for complete attribution.
We welcome contributions! See CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
- Bug Reports: GitHub Issues
- Feature Requests: GitHub Discussions
- Commercial Support: [email protected]