Thanks to visit codestin.com
Credit goes to github.com

Skip to content

withoutbg/withoutbg

Repository files navigation

withoutbg

AI-powered background removal with local and cloud options

PyPI License CI codecov

Remove backgrounds from images instantly with AI. Choose between local processing (free) or cloud API (best quality).

πŸš€ Quick Start

# 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

✨ Visual Examples

See the power of AI background removal in action:

Woman with confetti - before and after

Dog portrait - before and after

Pizza product - before and after

Feather detail - before and after

Perfect edge detection, hair details, and transparent backgrounds

πŸ’» Python API

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/")

πŸ–₯️ CLI Usage

Basic Usage

# 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

Cloud API

# 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

Batch Processing

# 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/

πŸ”§ Installation Options

Standard Installation

pip install withoutbg

Development

git clone https://github.com/withoutbg/withoutbg.git
cd withoutbg
pip install -e ".[dev]"

🎨 Examples

Basic Background Removal

import withoutbg

# Simple usage
output = withoutbg.remove_background("portrait.jpg")
output.save("portrait-withoutbg.png")

E-commerce Product Photos

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
)

Social Media Automation

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")

πŸ”‘ API Key Setup

  1. Get API Key: Visit withoutbg.com to get your API key
  2. Set Environment Variable:
    export WITHOUTBG_API_KEY="sk_your_api_key"
  3. Or pass directly in code:
    result = withoutbg.remove_background("image.jpg", api_key="sk_your_key")

πŸ—οΈ For Developers

Local Development

# 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/

πŸ“Š Usage Analytics

Track your API usage:

from withoutbg.api import StudioAPI

api = StudioAPI(api_key="sk_your_key")
usage = api.get_usage()
print(usage)

Commercial

API (Pay-per-use)

  • βœ… Best quality processing
  • βœ… Best quality results
  • βœ… 99.9% uptime SLA
  • βœ… Scalable infrastructure

Try API β†’

πŸ“š Documentation

πŸ› Issues & Support

πŸ€— Hugging Face

Find our models on Hugging Face:

πŸ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Third-Party Components

  • Depth Anything: Apache 2.0 License

See THIRD_PARTY_LICENSES.md for complete attribution.

🌟 Contributing

We welcome contributions! Please see our Contributing Guide for details.

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

πŸ“ˆ Star History

Star History Chart


🎯 Get best quality results with withoutbg.com