WithoutBG Snap Models
Free, high-quality background removal models powered by AI
This repository contains the Snap tier models for the withoutbg library - a complete set of ONNX models for local, free background removal processing.
π Model Overview
The Snap tier implements a sophisticated 3-stage pipeline for background removal:
| Model | File | Purpose | Input | Output | License |
|---|---|---|---|---|---|
| Depth Estimation | depth_anything_v2_vits_slim.onnx |
Stage 1: Depth map generation | RGB (518Γ518) | Inverse depth map | Apache 2.0 |
| Matting | snap_matting_0.1.0.onnx |
Stage 2: Initial background separation | RGBD (256Γ256) | Alpha channel (A1) | Apache 2.0 |
| Refiner | snap_refiner_0.1.0.onnx |
Stage 3: High-resolution refinement | RGB+D+A (original size) | Refined alpha (A2) | Apache 2.0 |
π Quick Start
Using the withoutbg library (Recommended)
pip install withoutbg
from withoutbg import remove_background
# Automatically downloads and uses these models
result = remove_background("image.jpg")
result.save("output.png")
π Processing Pipeline
Stage 1: Depth Estimation
- Model: Depth Anything V2 ViT-S (Apache 2.0 licensed)
- Input: RGB image (518Γ518 pixels, ImageNet normalized)
- Output: Inverse depth map (0-255 range)
- Purpose: Provides spatial understanding for better background separation
Stage 2: Matting
- Input: RGBD (RGB + depth concatenated as 4-channel input, 256Γ256)
- Output: Initial alpha channel (A1)
- Purpose: Performs initial foreground/background segmentation
Stage 3: Refining
- Input: RGB + depth + A1 (5-channel input at original resolution)
- Output: Refined alpha channel (A2) with high detail
- Purpose: Enhances edge quality and removes artifacts
π§ Technical Specifications
Model Details
- Framework: ONNX (compatible with ONNX Runtime)
- Providers: CPU, CUDA (automatically detected)
- Precision: FP32
- Total Size: ~140 MB (all three models)
Input Requirements
- Format: RGB images (any resolution)
- Preprocessing: Automatic resizing and normalization
- Output: RGBA images with transparent background
ποΈ Integration Examples
Batch Processing
from withoutbg import remove_background_batch
results = remove_background_batch([
"image1.jpg",
"image2.jpg",
"image3.jpg"
], output_dir="results/")
Custom Model Paths
from withoutbg.models import SnapModel
model = SnapModel(
depth_model_path="custom/depth_model.onnx",
matting_model_path="custom/matting_model.onnx",
refiner_model_path="custom/refiner_model.onnx"
)
result = model.remove_background("image.jpg")
π Licensing
Open Source Components
depth_anything_v2_vits_slim.onnx: Apache 2.0 License- Based on Depth-Anything V2
Snap Tier Components
snap_matting_0.1.0.onnx: Apache 2.0 Licensesnap_refiner_0.1.0.onnx: Apache 2.0 License- Free for commercial and non-commercial use
- Open source models for the Snap tier
π Related Links
- Main Library: withoutbg/withoutbg
- Documentation: withoutbg.com/docs
- Demo: Hugging Face Space
- Commercial Licensing: withoutbg.com/focus
π― Use Cases
- Development & Prototyping: Free local processing
- E-commerce: Product photo background removal
- Social Media: Profile picture editing
- Content Creation: Video thumbnails and graphics
π€ Contributing
We welcome improvements to the open source components:
- Depth Anything V2 optimizations: Submit PRs to improve inference speed
- Preprocessing enhancements: Better image handling and normalization
- Documentation: Examples, tutorials, and integration guides
- Bug reports: Issues with model loading or inference
π§ Support
- Technical Issues: GitHub Issues
- Community: GitHub Discussions
Try the models: Install pip install withoutbg and start removing backgrounds instantly!
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
π
Ask for provider support