AI-powered background removal with local and cloud options
Remove backgrounds from images instantly with AI. Choose between local processing (free) or cloud API (best quality).
# Install
pip install withoutbg
# Remove background (local processing)
withoutbg image.jpg
# Use cloud API for best quality processing
withoutbg image.jpg --api-key sk_your_api_key
See the power of AI background removal in action:
Perfect edge detection, hair details, and transparent backgrounds
from withoutbg import remove_background
# Local processing with Snap model (free)
result = remove_background("input.jpg")
result.save("output.png")
# Cloud processing with API (best quality)
result = remove_background("input.jpg", api_key="sk_your_key")
# Batch processing
from withoutbg import remove_background_batch
results = remove_background_batch(["img1.jpg", "img2.jpg"],
output_dir="results/")
# Process single image
withoutbg photo.jpg
# Specify output path
withoutbg photo.jpg --output result.png
# Use different format
withoutbg photo.jpg --format webp --quality 90
# Set API key via environment
export WITHOUTBG_API_KEY="sk_your_api_key"
withoutbg photo.jpg --use-api
# Or pass directly
withoutbg photo.jpg --api-key sk_your_key
# Process all images in directory
withoutbg photos/ --batch --output-dir results/
# With cloud API for best quality
withoutbg photos/ --batch --use-api --output-dir results/
pip install withoutbg
git clone https://github.com/withoutbg/withoutbg.git
cd withoutbg
pip install -e ".[dev]"
import withoutbg
# Simple usage
output = withoutbg.remove_background("portrait.jpg")
output.save("portrait-withoutbg.png")
import withoutbg
from pathlib import Path
# Process product catalog
product_images = Path("products").glob("*.jpg")
results = withoutbg.remove_background_batch(
list(product_images),
output_dir="catalog-withoutbg/",
api_key="sk_your_key" # Use for best quality
)
import withoutbg
from PIL import Image
# Remove background and add custom background
foreground = withoutbg.remove_background("selfie.jpg", api_key="sk_key")
background = Image.open("gradient_bg.jpg")
# Composite images
background.paste(foreground, (0, 0), foreground)
background.save("social_post.jpg")
- Get API Key: Visit withoutbg.com to get your API key
- Set Environment Variable:
export WITHOUTBG_API_KEY="sk_your_api_key"
- Or pass directly in code:
result = withoutbg.remove_background("image.jpg", api_key="sk_your_key")
# Clone repository
git clone https://github.com/withoutbg/withoutbg.git
cd withoutbg
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black src/ tests/
ruff check src/ tests/
# Type checking
mypy src/
Track your API usage:
from withoutbg.api import StudioAPI
api = StudioAPI(api_key="sk_your_key")
usage = api.get_usage()
print(usage)
- β Best quality processing
- β Best quality results
- β 99.9% uptime SLA
- β Scalable infrastructure
- API Reference - Complete API documentation
- Bug Reports: GitHub Issues
- Feature Requests: GitHub Discussions
- Commercial Support: [email protected]
Find our models on Hugging Face:
- withoutbg/snap - Open source Snap model
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- Depth Anything: Apache 2.0 License
See THIRD_PARTY_LICENSES.md for complete attribution.
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request