ONNX

WithoutBG Snap Models

Free, high-quality background removal models powered by AI

Apache 2.0 License ONNX Runtime

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

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

🎯 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


Try the models: Install pip install withoutbg and start removing backgrounds instantly!

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support