--- license: apache-2.0 --- # WithoutBG Snap Models **Free, high-quality background removal models powered by AI** [![Apache 2.0 License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![ONNX Runtime](https://img.shields.io/badge/Runtime-ONNX-orange.svg)](https://onnxruntime.ai/) 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. ## 📋 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) ```bash pip install withoutbg ``` ```python 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 ```python from withoutbg import remove_background_batch results = remove_background_batch([ "image1.jpg", "image2.jpg", "image3.jpg" ], output_dir="results/") ``` ### Custom Model Paths ```python 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](https://github.com/DepthAnything/Depth-Anything-V2) ### Snap Tier Components - **`snap_matting_0.1.0.onnx`**: Apache 2.0 License - **`snap_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](https://github.com/withoutbg/withoutbg) - **Documentation**: [withoutbg.com/docs](https://withoutbg.com/documentation) - **Demo**: [Hugging Face Space](https://huggingface.co/spaces/withoutbg/demo) - **Commercial Licensing**: [withoutbg.com/focus](https://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: 1. **Depth Anything V2 optimizations**: Submit PRs to improve inference speed 2. **Preprocessing enhancements**: Better image handling and normalization 3. **Documentation**: Examples, tutorials, and integration guides 4. **Bug reports**: Issues with model loading or inference ## 📧 Support - **Technical Issues**: [GitHub Issues](https://github.com/withoutbg/withoutbg/issues) - **Community**: [GitHub Discussions](https://github.com/withoutbg/withoutbg/discussions) --- **Try the models**: Install `pip install withoutbg` and start removing backgrounds instantly!