merahburam/remove-bg

A high-performance AI background removal API built with multiple state-of-the-art models. Remove backgrounds from images with professional quality results in seconds.

Public
130 runs

AI Background Remover

A high-performance AI background removal API built with multiple state-of-the-art models. Remove backgrounds from images with professional quality results in seconds.

Quick Start

# Basic usage - transparent background
result = predict(image="your-image.jpg")

# High quality with custom background
result = predict(
    image="portrait.jpg",
    model="isnet-general-use", 
    resize_for_speed=False
)

Features

Multiple AI Models

  • u2net - Fast, general purpose (default)
  • u2net_human_seg - Optimized for people and portraits
  • isnet-general-use - Highest quality, best edges

Performance Optimized

  • Smart Resizing - Automatically resizes large images for speed
  • Model Caching - Models load once and stay in memory
  • CPU Optimized - Fast processing without GPU requirements

Quality Options

  • Alpha Matting - Professional edge quality (on high-quality model)
  • Multiple Sizes - Works with images from 300x300 to 4000x4000 pixels
  • Format Support - PNG, JPG, JPEG, WebP, AVIF input

Parameters

Required

  • image: Input image file

Optional

  • model: AI model to use
  • "u2net" (default) - Fast and good quality
  • "u2net_human_seg" - Best for people/portraits
  • "isnet-general-use" - Highest quality with alpha matting

  • resize_for_speed: Resize large images for faster processing

  • true (default) - Resize images >1024px for speed
  • false - Keep original size for maximum quality

Use Cases & Recommendations

E-commerce & Product Photos

# Fast processing for product catalogs
result = predict(
    image="product.jpg",
    model="u2net",
    resize_for_speed=True
)

Portrait & People Photos

# Best quality for portraits
result = predict(
    image="portrait.jpg", 
    model="u2net_human_seg",
    resize_for_speed=False
)

High-End Photography

# Maximum quality with alpha matting
result = predict(
    image="professional_photo.jpg",
    model="isnet-general-use", 
    resize_for_speed=False
)

Performance Comparison

Model Speed Quality Best For
u2net Fast Good General use, products
u2net_human_seg Medium Great People, portraits
isnet-general-use Slower Excellent Professional, detailed

Technical Details

  • Processing Time: 1-3 seconds per image
  • Memory Usage: ~2GB RAM
  • Input Formats: PNG, JPG, JPEG, WebP, AVIF
  • Output Format: PNG with transparency
  • Max Resolution: 4000x4000 pixels recommended

Tips for Best Results

Input Images

  • Use high-resolution images for best quality
  • Clear separation between subject and background helps
  • Good lighting improves results

Model Selection

  • General photos: Start with u2net
  • People/faces: Use u2net_human_seg
  • Professional work: Use isnet-general-use with resize_for_speed=false

Speed vs Quality

  • Enable resize_for_speed for batch processing
  • Disable resize_for_speed for final/professional output
  • isnet-general-use gives best edges but takes longer

Deployment Ready

This model is optimized for production deployment: - Models pre-download during build for instant startup - Efficient memory usage - CPU-only for reliable scaling - Smart caching reduces processing time

API Response

Returns a PNG image with transparent background. The removed background is fully transparent, making it easy to composite onto any new background.

Credits & Licenses

This model uses the following open-source projects:

  • rembg by Daniel Gatis - MIT License
  • U-2-Net by Xuebin Qin et al. - Apache 2.0 License
  • IS-Net by Xuebin Qin et al. - Apache 2.0 License

License

This implementation is provided as-is for educational and commercial use. The underlying AI models retain their original licenses as listed above.