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
| 7 |
+
**Free, high-quality background removal models powered by AI**
|
| 8 |
+
|
| 9 |
+
[](https://opensource.org/licenses/Apache-2.0)
|
| 10 |
+
[](https://onnxruntime.ai/)
|
| 11 |
+
|
| 12 |
+
This repository contains the **Snap tier** models for the [withoutbg](https://github.com/withoutbg/withoutbg) library - a complete set of ONNX models for local, free background removal processing.
|
| 13 |
+
|
| 14 |
+
## π Model Overview
|
| 15 |
+
|
| 16 |
+
The Snap tier implements a sophisticated 3-stage pipeline for background removal:
|
| 17 |
+
|
| 18 |
+
| Model | File | Purpose | Input | Output | License |
|
| 19 |
+
|-------|------|---------|-------|---------|---------|
|
| 20 |
+
| **Depth Estimation** | `depth_anything_v2_vits_slim.onnx` | Stage 1: Depth map generation | RGB (518Γ518) | Inverse depth map | Apache 2.0 |
|
| 21 |
+
| **Matting** | `snap_matting_0.1.0.onnx` | Stage 2: Initial background separation | RGBD (256Γ256) | Alpha channel (A1) | Apache 2.0 |
|
| 22 |
+
| **Refiner** | `snap_refiner_0.1.0.onnx` | Stage 3: High-resolution refinement | RGB+D+A (original size) | Refined alpha (A2) | Apache 2.0 |
|
| 23 |
+
|
| 24 |
+
## π Quick Start
|
| 25 |
+
|
| 26 |
+
### Using the withoutbg library (Recommended)
|
| 27 |
+
|
| 28 |
+
```bash
|
| 29 |
+
pip install withoutbg
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
```python
|
| 33 |
+
from withoutbg import remove_background
|
| 34 |
+
|
| 35 |
+
# Automatically downloads and uses these models
|
| 36 |
+
result = remove_background("image.jpg")
|
| 37 |
+
result.save("output.png")
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
## π Processing Pipeline
|
| 42 |
+
|
| 43 |
+
### Stage 1: Depth Estimation
|
| 44 |
+
- **Model**: Depth Anything V2 ViT-S (Apache 2.0 licensed)
|
| 45 |
+
- **Input**: RGB image (518Γ518 pixels, ImageNet normalized)
|
| 46 |
+
- **Output**: Inverse depth map (0-255 range)
|
| 47 |
+
- **Purpose**: Provides spatial understanding for better background separation
|
| 48 |
+
|
| 49 |
+
### Stage 2: Matting
|
| 50 |
+
- **Input**: RGBD (RGB + depth concatenated as 4-channel input, 256Γ256)
|
| 51 |
+
- **Output**: Initial alpha channel (A1)
|
| 52 |
+
- **Purpose**: Performs initial foreground/background segmentation
|
| 53 |
+
|
| 54 |
+
### Stage 3: Refining
|
| 55 |
+
- **Input**: RGB + depth + A1 (5-channel input at original resolution)
|
| 56 |
+
- **Output**: Refined alpha channel (A2) with high detail
|
| 57 |
+
- **Purpose**: Enhances edge quality and removes artifacts
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
## π§ Technical Specifications
|
| 61 |
+
|
| 62 |
+
### Model Details
|
| 63 |
+
- **Framework**: ONNX (compatible with ONNX Runtime)
|
| 64 |
+
- **Providers**: CPU, CUDA (automatically detected)
|
| 65 |
+
- **Precision**: FP32
|
| 66 |
+
- **Total Size**: ~140 MB (all three models)
|
| 67 |
+
|
| 68 |
+
### Input Requirements
|
| 69 |
+
- **Format**: RGB images (any resolution)
|
| 70 |
+
- **Preprocessing**: Automatic resizing and normalization
|
| 71 |
+
- **Output**: RGBA images with transparent background
|
| 72 |
+
|
| 73 |
+
## ποΈ Integration Examples
|
| 74 |
+
|
| 75 |
+
### Batch Processing
|
| 76 |
+
```python
|
| 77 |
+
from withoutbg import remove_background_batch
|
| 78 |
+
|
| 79 |
+
results = remove_background_batch([
|
| 80 |
+
"image1.jpg",
|
| 81 |
+
"image2.jpg",
|
| 82 |
+
"image3.jpg"
|
| 83 |
+
], output_dir="results/")
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
### Custom Model Paths
|
| 87 |
+
```python
|
| 88 |
+
from withoutbg.models import SnapModel
|
| 89 |
+
|
| 90 |
+
model = SnapModel(
|
| 91 |
+
depth_model_path="custom/depth_model.onnx",
|
| 92 |
+
matting_model_path="custom/matting_model.onnx",
|
| 93 |
+
refiner_model_path="custom/refiner_model.onnx"
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
result = model.remove_background("image.jpg")
|
| 97 |
+
```
|
| 98 |
+
|
| 99 |
+
## π Licensing
|
| 100 |
+
|
| 101 |
+
### Open Source Components
|
| 102 |
+
- **`depth_anything_v2_vits_slim.onnx`**: Apache 2.0 License
|
| 103 |
+
- Based on [Depth-Anything V2](https://github.com/DepthAnything/Depth-Anything-V2)
|
| 104 |
+
- Free for commercial and non-commercial use
|
| 105 |
+
- Source code available
|
| 106 |
+
|
| 107 |
+
### Snap Tier Components
|
| 108 |
+
- **`snap_matting_0.1.0.onnx`**: Apache 2.0 License
|
| 109 |
+
- **`snap_refiner_0.1.0.onnx`**: Apache 2.0 License
|
| 110 |
+
- Free for commercial and non-commercial use
|
| 111 |
+
- Open source models for the Snap tier
|
| 112 |
+
|
| 113 |
+
## π Related Links
|
| 114 |
+
|
| 115 |
+
- **Main Library**: [withoutbg/withoutbg](https://github.com/withoutbg/withoutbg)
|
| 116 |
+
- **Documentation**: [withoutbg.com/docs](https://withoutbg.com/documentation)
|
| 117 |
+
- **Demo**: [Hugging Face Space](https://huggingface.co/spaces/withoutbg/demo)
|
| 118 |
+
- **Commercial Licensing**: [withoutbg.com/focus](https://withoutbg.com/focus)
|
| 119 |
+
|
| 120 |
+
## π― Use Cases
|
| 121 |
+
|
| 122 |
+
- **Development & Prototyping**: Free local processing
|
| 123 |
+
- **E-commerce**: Product photo background removal
|
| 124 |
+
- **Social Media**: Profile picture editing
|
| 125 |
+
- **Content Creation**: Video thumbnails and graphics
|
| 126 |
+
|
| 127 |
+
## π€ Contributing
|
| 128 |
+
|
| 129 |
+
We welcome improvements to the open source components:
|
| 130 |
+
|
| 131 |
+
1. **Depth Anything V2 optimizations**: Submit PRs to improve inference speed
|
| 132 |
+
2. **Preprocessing enhancements**: Better image handling and normalization
|
| 133 |
+
3. **Documentation**: Examples, tutorials, and integration guides
|
| 134 |
+
4. **Bug reports**: Issues with model loading or inference
|
| 135 |
+
|
| 136 |
+
## π§ Support
|
| 137 |
+
|
| 138 |
+
- **Technical Issues**: [GitHub Issues](https://github.com/withoutbg/withoutbg/issues)
|
| 139 |
+
- **Community**: [GitHub Discussions](https://github.com/withoutbg/withoutbg/discussions)
|
| 140 |
+
|
| 141 |
+
---
|
| 142 |
+
|
| 143 |
+
**Try the models**: Install `pip install withoutbg` and start removing backgrounds instantly!
|